-
-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Labels
Description
Describe the bug
Native namespace packages (without __init__.py modules) trigger the following kind of error when attempting to retrieve the top package's path:
ERROR - mkdocstrings.handlers.python: Collection failed: <module 'bot' (namespace)> is a built-in module
Traceback (most recent call last):
File "/home/dadyarri/projects/bjorn/venv_bjorn/lib/python3.8/site-packages/pytkdocs/cli.py", line 179, in main
print(json.dumps(process_json(line)))
File "/home/dadyarri/projects/bjorn/venv_bjorn/lib/python3.8/site-packages/pytkdocs/cli.py", line 116, in process_json
return process_config(json.loads(json_input))
File "/home/dadyarri/projects/bjorn/venv_bjorn/lib/python3.8/site-packages/pytkdocs/cli.py", line 98, in process_config
serialized_obj = serialize_object(obj)
File "/home/dadyarri/projects/bjorn/venv_bjorn/lib/python3.8/site-packages/pytkdocs/serializer.py", line 143, in serialize_object
relative_file_path=obj.relative_file_path,
File "/home/dadyarri/projects/bjorn/venv_bjorn/lib/python3.8/site-packages/pytkdocs/objects.py", line 185, in relative_file_path
top_package_path = Path(inspect.getabsfile(top_package)).parent
File "/usr/lib/python3.8/inspect.py", line 720, in getabsfile
_filename = getsourcefile(object) or getfile(object)
File "/usr/lib/python3.8/inspect.py", line 696, in getsourcefile
filename = getfile(object)
File "/usr/lib/python3.8/inspect.py", line 659, in getfile
raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module 'bot' (namespace)> is a built-in module
To Reproduce
Simply try to collect documentation for a native namespace package.
Expected behavior
No exception. We should find another way to determine the top package's path in that case.
Reference: mkdocstrings/mkdocstrings#79 (comment)