From 6fed3d7d4e41aac2545eafb3e78b03c1ebb01d3e Mon Sep 17 00:00:00 2001 From: Douglas Needham Date: Mon, 13 Apr 2026 23:58:36 -0400 Subject: [PATCH] Fix for issue #10969 - Pylint skipping similarly named project directory. - Because _discover_files() will falsely ignore a with a name like `applications_api` after walking across one named `applications`, add the os directory separator to the end of what is a known directory (because of the fact that it has a file named `__init__.py` in it). --- doc/whatsnew/fragments/10969.bugfix | 7 +++++++ pylint/lint/pylinter.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 doc/whatsnew/fragments/10969.bugfix diff --git a/doc/whatsnew/fragments/10969.bugfix b/doc/whatsnew/fragments/10969.bugfix new file mode 100644 index 0000000000..e8584fb235 --- /dev/null +++ b/doc/whatsnew/fragments/10969.bugfix @@ -0,0 +1,7 @@ +Fix an issue where discovery can miss a similarly named directory if a shorter named directory is processed first. + +If you have directories named say `applications` and `applications_api` in a +project, and the former is encountered by the tree walk first during discovery, +the second directory would be skipped even if it was a valid package. This fixes +the issue by appending the OS filepath separator to the name in the case where +the path was known to be a directory due to having an `__init__.py` in it. diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index d3399ecba4..101cbbcdd2 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -685,7 +685,7 @@ def _discover_files(self, files_or_modules: Sequence[str]) -> Iterator[str]: continue if "__init__.py" in files: - skip_subtrees.append(root) + skip_subtrees.append(root + os.sep) yield root else: yield from (