Skip to content

bug: Erroneous detection of cyclic alias #424

@fg91

Description

@fg91

Description of the bug

In a library with the following namespaced module structure

├── index.py
├── __init__.py

and the following content of the init

from .index import (
    index,
)

I get the following error when generating docs using mkdocstrings:

  File "/usr/local/venv/lib/python3.11/site-packages/griffe/_internal/models.py", line 1505, in members
    final_target = self.final_target
                   ^^^^^^^^^^^^^^^^^
  File "/usr/local/venv/lib/python3.11/site-packages/griffe/_internal/models.py", line 2104, in final_target
    target = target.target  # type: ignore[assignment]
             ^^^^^^^^^^^^^
  File "/usr/local/venv/lib/python3.11/site-packages/griffe/_internal/models.py", line 2069, in target
    self.resolve_target()
  File "/usr/local/venv/lib/python3.11/site-packages/griffe/_internal/models.py", line 2133, in resolve_target
    raise CyclicAliasError([self.target_path])
griffe._internal.exceptions.CyclicAliasError: Cyclic aliases detected:
  my_library.index.index

Expected behavior

Of course one can argue that simply renaming the module or the function imported from the module avoids this issue. However, this is valid and idiomatic python and I would have expected that the api reference generation works.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions