-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Bug 🪲Needs astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)Needs astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds an astroid update (probably a release too) before being mergable
Description
Bug description
Trying to use pylint on a file called 'pytest' gives errors, originating from the file astroid/brain/brain_pytest.py, even if the actual file-under-test is empty.
Renaming the file-under-test from pytest
to e.g. foobar
removes the errors.
Configuration
No response
Command used
$ touch pytest
$ cat pytest
$ pylint -v pytest
Pylint output
No config file found, using default configuration
*************
<?>:16:4: W0622: Redefining built-in 'exit' (redefined-builtin)
*************
<?>:4:4: W0611: Unused import _pytest.mark (unused-import)
*************
<?>:5:4: W0611: Unused import _pytest.recwarn (unused-import)
*************
<?>:6:4: W0611: Unused import _pytest.runner (unused-import)
*************
<?>:7:4: W0611: Unused import _pytest.python (unused-import)
*************
<?>:8:4: W0611: Unused import _pytest.skipping (unused-import)
*************
<?>:9:4: W0611: Unused import _pytest.assertion (unused-import)
*************
<?>:36:4: W0611: Unused import _pytest.freeze_support (unused-import)
*************
<?>:40:8: W0611: Unused import _pytest.genscript (unused-import)
*************
<?>:46:4: W0611: Unused import _pytest.debugging (unused-import)
*************
<?>:50:8: W0611: Unused import _pytest.pdb (unused-import)
*************
<?>:56:4: W0611: Unused import _pytest.fixtures (unused-import)
Expected behavior
Without knowing more about internals, my view is that:
- It is not correct that a hook for 'pytest' is included just because the module-to-be-linted is called pytest. There may or may not be a relation. In this case, the local pytest is intended to be a wrapper around calling pytest, but is not actually importing pytest (it will call it via subprocess).
- Even if it is warranted that real pytest imports are done via astroid, the user should not be presented with pylint errors from that module, because they only asked to lint the local module-under-test.
Pylint version
pylint 2.15.5
astroid 2.12.12
Python 3.10.8 (main, Nov 19 2022, 21:53:32) [GCC 11.3.0]
OS / Environment
Gentoo Linux
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Bug 🪲Needs astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)Needs astroid updateNeeds an astroid update (probably a release too) before being mergableNeeds an astroid update (probably a release too) before being mergable