From 3b0149fba6026b0f5f06ef2141baf28eae0b1be0 Mon Sep 17 00:00:00 2001 From: Eric McDonald Date: Thu, 10 Nov 2022 18:00:00 -0800 Subject: [PATCH] Deduplicate module file paths to prevent redundant scans. Closes #6242 and #4053. --- pylint/lint/pylinter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pylint/lint/pylinter.py b/pylint/lint/pylinter.py index 66455bfb109..2c9318713a9 100644 --- a/pylint/lint/pylinter.py +++ b/pylint/lint/pylinter.py @@ -14,7 +14,7 @@ import traceback import warnings from collections import defaultdict -from collections.abc import Callable, Iterator, Sequence +from collections.abc import Callable, Iterator, MutableSet, Sequence from io import TextIOWrapper from pathlib import Path from re import Pattern @@ -878,8 +878,12 @@ def _iterate_file_descrs( The returned generator yield one item for each Python module that should be linted. """ + seen_filepaths: MutableSet[str] = set() # For deduplication of paths. for descr in self._expand_files(files_or_modules): name, filepath, is_arg = descr["name"], descr["path"], descr["isarg"] + if filepath in seen_filepaths: + continue + seen_filepaths.add(filepath) if self.should_analyze_file(name, filepath, is_argument=is_arg): yield FileItem(name, filepath, descr["basename"])