python: simplify code in Package.collect()

The path of Package is already the `__init__.py` file, and we're already
assured it's a file.
This commit is contained in:
Ran Benita 2023-05-19 14:56:37 +03:00
parent 519f351b4f
commit baaa67dfb9
1 changed files with 5 additions and 5 deletions

View File

@ -745,11 +745,11 @@ class Package(Module):
def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
this_path = self.path.parent
init_module = this_path / "__init__.py"
if init_module.is_file() and path_matches_patterns(
init_module, self.config.getini("python_files")
):
yield Module.from_parent(self, path=init_module)
# Always collect the __init__ first.
if path_matches_patterns(self.path, self.config.getini("python_files")):
yield Module.from_parent(self, path=self.path)
pkg_prefixes: Set[Path] = set()
for direntry in visit(str(this_path), recurse=self._recurse):
path = Path(direntry.path)