Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--recursive option does not find .py files in sub-directories of packages #9187

Open
GrimzEcho opened this issue Oct 24, 2023 · 3 comments
Open
Labels
Bug 🪲 Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@GrimzEcho
Copy link

GrimzEcho commented Oct 24, 2023

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

@GrimzEcho GrimzEcho added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 24, 2023
@scorphus
Copy link

Hey, @BrianHVB 👋

Any chance you have that example structure available as a repo?

Thanks!

@scorphus
Copy link

Here's a code sample that reproduces this issue: https://github.com/scorphus/pylint-issue-9187

@GrimzEcho
Copy link
Author

@scorphus - Thanks for adding a sample repo. I was on vacation for the past couple of weeks and just saw this today.

@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

4 participants