From 9b607ed04feba86870f77bdfd26eaf47063551ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Thu, 26 Dec 2024 18:32:14 +0100 Subject: [PATCH] Don't filter manual selected file --- prospector/finder.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/prospector/finder.py b/prospector/finder.py index 19562308..61e569dc 100644 --- a/prospector/finder.py +++ b/prospector/finder.py @@ -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): @@ -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]: @@ -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]: @@ -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.