pylint
pylint copied to clipboard
--recursive option does not find .py files in sub-directories of packages
Bug description
When running pylint --recursive=y on a directory that contains both a package and a sub-directory, pylint correctly locates and lints all py files, both those in the non-package sub-directory and those in the package.
However, when running pylint --resursive=y on a package that contains both a sub-package and a sub-directory, pylint will not locate or lint any files in the sub-directory.
Example structure:
- tmp
- src1
- my_package
* __init__.py
* foo.py
- scripts
* bar.py
- src2
* __init__.py
- my_package
* __init__.py
* foo.py
- scripts
* bar.py
The only difference between src1 and src2 is that src2 is a package.
Running pylint --recursive=y ./tmp/src1 will find/lint both foo.py and bar.py.
Running pylint --recursive=y ./tmp/src2 will not find/lint bar.py
Configuration
No response
Command used
pylint --recursive ./src2
Pylint output
************* Module src2.package1.foo
lint-test/src2/package1/foo.py:1:0: C0114: Missing module docstring (missing-module-docstring)
lint-test/src2/package1/foo.py:1:0: C0104: Disallowed name "foo" (disallowed-name)
lint-test/src2/package1/foo.py:2:0: W0107: Unnecessary pass statement (unnecessary-pass)
lint-test/src2/package1/foo.py:1:0: W0611: Unused import sys (unused-import)
Expected behavior
bar.py is linted as intended by #5682
************* Module foo
lint-test/src1/scripts/foo.py:1:0: C0114: Missing module docstring (missing-module-docstring)
lint-test/src1/scripts/foo.py:1:0: C0104: Disallowed name "foo" (disallowed-name)
lint-test/src1/scripts/foo.py:2:0: W0107: Unnecessary pass statement (unnecessary-pass)
lint-test/src1/scripts/foo.py:1:0: W0611: Unused import sys (unused-import)
************* Module package1.foo
lint-test/src1/package1/foo.py:1:0: C0114: Missing module docstring (missing-module-docstring)
lint-test/src1/package1/foo.py:1:0: C0104: Disallowed name "foo" (disallowed-name)
lint-test/src1/package1/foo.py:2:0: W0107: Unnecessary pass statement (unnecessary-pass)
lint-test/src1/package1/foo.py:1:0: W0611: Unused import sys (unused-import)
Pylint version
pylint 2.17.7
astroid 2.15.6
Python 3.7.3 (default, Oct 11 2023, 09:51:27)
OS / Environment
Debian 9
Additional dependencies
No response
Hey, @BrianHVB 👋
Any chance you have that example structure available as a repo?
Thanks!
Here's a code sample that reproduces this issue: https://github.com/scorphus/pylint-issue-9187
@scorphus - Thanks for adding a sample repo. I was on vacation for the past couple of weeks and just saw this today.