Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] committed Aug 27, 2024
1 parent be98a83 commit 2286555
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 73 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
To exclude modules, see https://pdoc.dev/docs/pdoc.html#exclude-submodules-from-being-documented.
([#728](https://github.com/mitmproxy/pdoc/pull/728), @mhils)
- Fix a bug where pdoc would crash when importing pyi files.
([#732](https://github.com/mitmproxy/pdoc/pull/732), @mhils)
- Fix a bug where subclasses of TypedDict subclasses would not render correctly.
([#729](https://github.com/mitmproxy/pdoc/pull/729), @mhils)

Expand Down
10 changes: 7 additions & 3 deletions pdoc/doc_pyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ def find_stub_file(module_name: str) -> Path | None:
def _import_stub_file(module_name: str, stub_file: Path) -> types.ModuleType:
"""
Import the type stub outside of the normal import machinery.
Note that currently, for objects imported by the stub file, the _original_ module
is used and not the corresponding stub file.
"""
sys.path_hooks.append(
importlib.machinery.FileFinder.path_hook((importlib.machinery.SourceFileLoader, ['.pyi']))
importlib.machinery.FileFinder.path_hook(
(importlib.machinery.SourceFileLoader, [".pyi"])
)
)
try:
loader = importlib.machinery.SourceFileLoader(module_name, str(stub_file))
spec = importlib.util.spec_from_file_location(module_name, stub_file, loader=loader)
spec = importlib.util.spec_from_file_location(
module_name, stub_file, loader=loader
)
assert spec is not None
m = importlib.util.module_from_spec(spec)
loader.exec_module(m)
Expand Down
Loading

0 comments on commit 2286555

Please sign in to comment.