Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't filter manual selected file #707

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 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,10 +110,10 @@ 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]:
def directories(self) -> set[Path]:
"""
Lists every directory found from the given configuration, regardless of its contents.

Expand Down
Loading