Describe the bug
If I reexport an external library through one file and use the types from that reexported library in another file, it will break with a griffe.exceptions.AliasResolutionError.
This might be a feature requests, but I wasn't sure.
To Reproduce
Given a package called docstring_thing and two files like this:
# b.py import polars as polars
# a.py from docstring_thing.b import polars def my_func(input: polars.LazyFrame) -> polars.LazyFrame: """ Args: input: The first parameter. Returns: The return value. """ pass
mkdocs serve will break with griffe.exceptions.AliasResolutionError: Could not resolve polars
INFO - Building documentation... INFO - Cleaning site directory ERROR - Error building page 'index.md': Could not resolve polars Traceback (most recent call last): File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/plugin.py", line 78, in _get_item_url return self._url_map[identifier] KeyError: 'docstring_thing.b.polars.LazyFrame' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/dataclasses.py", line 1111, in _resolve_target resolved = self.modules_collection[self.target_path] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/mixins.py", line 27, in __getitem__ return self.members[parts[0]] # type: ignore[attr-defined] KeyError: 'polars' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/bin/mkdocs", line 8, in <module> sys.exit(cli()) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/__main__.py", line 234, in serve_command serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 83, in serve builder(config) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 76, in builder build(config, live_server=live_server, dirty=dirty) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 329, in build _build_page(file.page, config, doc_files, nav, env, dirty) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 234, in _build_page output = config.plugins.run_event('post_page', output, page=page, config=config) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs/plugins.py", line 520, in run_event result = method(item, **kwargs) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/plugin.py", line 205, in on_post_page fixed_output, unmapped = fix_refs(output, url_mapper) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/references.py", line 191, in fix_refs html = AUTO_REF_RE.sub(fix_ref(url_mapper, unmapped), html) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/references.py", line 157, in inner url = url_mapper(unescape(identifier)) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/plugin.py", line 107, in get_item_url url = self._get_item_url(identifier, fallback) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocs_autorefs/plugin.py", line 83, in _get_item_url new_identifiers = fallback(identifier) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocstrings/handlers/base.py", line 531, in get_anchors anchors = handler.get_anchors(handler.collect(identifier, fallback_config)) File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/mkdocstrings_handlers/python/handler.py", line 223, in collect doc_object = self._modules_collection[identifier] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/mixins.py", line 28, in __getitem__ return self.members[parts[0]][parts[1:]] # type: ignore[attr-defined] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/mixins.py", line 28, in __getitem__ return self.members[parts[0]][parts[1:]] # type: ignore[attr-defined] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/mixins.py", line 28, in __getitem__ return self.members[parts[0]][parts[1:]] # type: ignore[attr-defined] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/dataclasses.py", line 817, in __getitem__ return self.target[key] File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/dataclasses.py", line 1078, in target self.resolve_target() File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/dataclasses.py", line 1105, in resolve_target self._resolve_target() File "/home/sras/.cache/pypoetry/virtualenvs/docstring-thing-Gq5GOpo2-py3.10/lib/python3.10/site-packages/griffe/dataclasses.py", line 1113, in _resolve_target raise AliasResolutionError(self.target_path) from error griffe.exceptions.AliasResolutionError: Could not resolve polars
Expected behavior
I would want it not to break. Linking to the actual library class is not needed.
Screenshots
System (please complete the following information):
mkdocstrings-pythonversion: 0.20- Python version: 3.10
- OS: Ubuntu 22.04.1 LTS (in WSL)
Additional context
I'm reexporting it because I need to register extra functions. I'm using a linter to force all polars imports to go through that file to be sure that the functions are registered.