-
-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Description of the bug
Use this project with mkdocstrings-python and it reported an error below:
File ".../lib/python3.10/site-packages/mkdocstrings/extension.py", line 128, in run
html, handler, data = self._process_block(identifier, block, heading_level)
File ".../lib/python3.10/site-packages/mkdocstrings/extension.py", line 210, in _process_block
data: CollectorItem = handler.collect(identifier, options)
File ".../lib/python3.10/site-packages/mkdocstrings_handlers/python/handler.py", line 315, in collect
loader.load(
File ".../lib/python3.10/site-packages/griffe/loader.py", line 223, in load
top_module = self._load_package(package, submodules=submodules)
File ".../lib/python3.10/site-packages/griffe/loader.py", line 521, in _load_package
top_module = self._load_module(package.name, package.path, submodules=submodules)
File ".../lib/python3.10/site-packages/griffe/loader.py", line 545, in _load_module
return self._load_module_path(module_name, module_path, submodules=submodules, parent=parent)
File ".../lib/python3.10/site-packages/griffe/loader.py", line 568, in _load_module_path
elif module_path.suffix in {".py", ".pyi"}:
AttributeError: 'str' object has no attribute 'suffix'
Attaching a pdb shows that module_path is a str instead of PathLike. The package variable in loader.py:223 is:
Package(name='(package name)', path='(correct absolute package path)', stubs=None)
despite that Package.path is marked PathLike in type signature, so looks like there's something wrong here.
I found some logic https://github.com/mkdocstrings/griffe/blob/main/src/griffe/loader.py#L202C53-L202C61 that tries to populate Package.path from module_obj.__path__ (which is an str). Additionally, the Python environment injects custom sitedirs. Not sure if they are related.
To Reproduce
Unfortunately it's a bit difficult to reproduce on an proprietary code base, but we're happy to provide more information according to request.
Full traceback
(See above)
Expected behavior
mkdocs correctly outputs the Python documentation
Environment information
- __System__: Linux-...
- __Python__: cpython 3.10.13 (.../bin/python)
- __Environment variables__:
- __Installed packages__:
- `griffe` v0.45.0