Skip to content

Commit 3b0149f

Browse files
committed
Deduplicate module file paths to prevent redundant scans.
Closes #6242 and #4053.
1 parent c289271 commit 3b0149f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pylint/lint/pylinter.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import traceback
1515
import warnings
1616
from collections import defaultdict
17-
from collections.abc import Callable, Iterator, Sequence
17+
from collections.abc import Callable, Iterator, MutableSet, Sequence
1818
from io import TextIOWrapper
1919
from pathlib import Path
2020
from re import Pattern
@@ -878,8 +878,12 @@ def _iterate_file_descrs(
878878
879879
The returned generator yield one item for each Python module that should be linted.
880880
"""
881+
seen_filepaths: MutableSet[str] = set() # For deduplication of paths.
881882
for descr in self._expand_files(files_or_modules):
882883
name, filepath, is_arg = descr["name"], descr["path"], descr["isarg"]
884+
if filepath in seen_filepaths:
885+
continue
886+
seen_filepaths.add(filepath)
883887
if self.should_analyze_file(name, filepath, is_argument=is_arg):
884888
yield FileItem(name, filepath, descr["basename"])
885889

0 commit comments

Comments
 (0)