Skip to content

Commit

Permalink
fix: Fix async loader (passing parent)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Nov 13, 2021
1 parent 4b8b85d commit 57e866e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/griffe/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ async def load_module(
module_name, module_path = self._module_name_and_path(module, search_paths)
return await self._load_module_path(module_name, module_path, submodules=submodules)

async def _load_module_path(self, module_name: str, module_path: Path, submodules: bool = True) -> Module:
async def _load_module_path(
self,
module_name: str,
module_path: Path,
submodules: bool = True,
parent: Module | None = None,
) -> Module:
logger.debug(f"Loading path {module_path}")
code = await read_async(module_path)
lines_collection[module_path] = code.splitlines(keepends=False)
Expand All @@ -190,6 +196,7 @@ async def _load_module_path(self, module_name: str, module_path: Path, submodule
filepath=module_path,
code=code,
extensions=self.extensions,
parent=parent,
docstring_parser=self.docstring_parser,
docstring_options=self.docstring_options,
)
Expand All @@ -212,7 +219,9 @@ async def _load_submodule(self, module: Module, subparts: NamePartsType, subpath
except KeyError:
logger.debug(f"Skipping (not importable) {subpath}")
else:
member_parent[subparts[-1]] = await self._load_module_path(subparts[-1], subpath, submodules=False)
member_parent[subparts[-1]] = await self._load_module_path(
subparts[-1], subpath, submodules=False, parent=member_parent
)


def _module_depth(name_parts_and_path: NamePartsAndPathType) -> int:
Expand Down

0 comments on commit 57e866e

Please sign in to comment.