Skip to content

Commit

Permalink
Don't filter manual selected file
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 26, 2024
1 parent 09dc59d commit 27b84d6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions prospector/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def make_syspath(self) -> list[Path]:
def is_excluded(self, path: Path) -> bool:
return any(filt(path) for filt in self._exclusion_filters)

def _filter(self, paths: Iterable[Path]) -> list[Path]:
return [path for path in paths if not self.is_excluded(path)]
def _filter(self, paths: Iterable[Path]) -> set[Path]:
return {path for path in paths if not self.is_excluded(path)}

def _walk(self, directory: Path) -> Iterator[Path]:
if not self.is_excluded(directory):
Expand All @@ -72,22 +72,25 @@ def _walk(self, directory: Path) -> Iterator[Path]:
yield path

@property
def files(self) -> list[Path]:
def files(self) -> set[Path]:
"""
List every individual file found from the given configuration.
This method is useful for tools which require an explicit list of files to check.
"""
files = set()
for path in self._provided_files:
files.add(path)

for directory in self.directories:
for path in self._walk(directory):
if path.is_file():
files.add(path)

return self._filter(files)
files = self._filter(files)

for path in self._provided_files:
files.add(path)

return files

@property
def python_packages(self) -> list[Path]:
Expand All @@ -97,7 +100,7 @@ def python_packages(self) -> list[Path]:
This method is useful for passing to tools which will do their own discovery of python files.
"""
return self._filter(d for d in self.directories if is_python_package(d))
return [d for d in self.directories if is_python_package(d)]

@property
def python_modules(self) -> list[Path]:
Expand All @@ -107,7 +110,7 @@ def python_modules(self) -> list[Path]:
This method is useful for passing to tools which will do their own discovery of python files.
"""
return self._filter(f for f in self.files if is_python_module(f))
return [f for f in self.files if is_python_module(f)]

@property
def directories(self) -> list[Path]:
Expand Down

0 comments on commit 27b84d6

Please sign in to comment.