From f2961dcff6c1a8159ad466801dc5ae65cd17142b Mon Sep 17 00:00:00 2001 From: Akhil Kamat Date: Tue, 27 Aug 2024 16:23:27 -0400 Subject: [PATCH] Fix to maintain order of package paths (#9887) (cherry picked from commit 8314743abec3106c21c364cfc2976713af245325) --- doc/whatsnew/fragments/9883.bugfix | 3 +++ pylint/lint/pylinter.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 doc/whatsnew/fragments/9883.bugfix diff --git a/doc/whatsnew/fragments/9883.bugfix b/doc/whatsnew/fragments/9883.bugfix new file mode 100644 index 0000000000..51a1a935c0 --- /dev/null +++ b/doc/whatsnew/fragments/9883.bugfix @@ -0,0 +1,3 @@ +Fix to address indeterminacy of error message in case a module name is same as another in a separate namespace. + +Refs #9883 diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index eff15cc444..dce95e0036 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -666,10 +666,12 @@ def check(self, files_or_modules: Sequence[str]) -> None: ) extra_packages_paths = list( - { - discover_package_path(file_or_module, self.config.source_roots) - for file_or_module in files_or_modules - } + dict.fromkeys( + [ + discover_package_path(file_or_module, self.config.source_roots) + for file_or_module in files_or_modules + ] + ).keys() ) # TODO: Move the parallel invocation into step 3 of the checking process