Skip to content

bug: [regression 0.46] Does not find inherited methods #295

@llucax

Description

@llucax

Description of the bug

I have a project linking to Sub.__init__, where Sub.__init__ is not actually defined but inherited from Parent.__init__. This worked fine until we upgraded to griffe 0.46.

To Reproduce

git clone https://github.com/frequenz-floss/frequenz-sdk-python.git
cd frequenz-sdk-python
python3.11 -m venv .venv
. .venv/bin/activate
python -m pip install .[dev-mkdocs]
python -m pip show griffe # Shows 0.46
mkdocs serve # fails mkdocs_autorefs: reference/frequenz/sdk/actor/index.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'

(Sorry it is a very big project, my intuition is it should be easy to reproduce with a small code snippet just with a parent and sub-class, but if this is enough info to pin-point the bug I prefer not to spend the time to provide the proper MRE).

Full traceback

No traceback, just error message (warnings, but I use --strict) and a deprecation:

INFO    -  DeprecationWarning: Passing multiple extensions as a single list or tuple is deprecated. Please pass them as separate arguments instead.
             File "/tmp/frequenz-sdk-python/.venv/lib/python3.11/site-packages/mkdocstrings_handlers/python/handler.py", line 299, in collect
               extensions=load_extensions(extensions),
             File "/tmp/frequenz-sdk-python/.venv/lib/python3.11/site-packages/griffe/extensions/base.py", line 481, in load_extensions
               warnings.warn(
INFO    -  DeprecationWarning: This method is now a property and should be accessed as such (without parentheses).
             File "/tmp/frequenz-sdk-python/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 303, in call
               return __obj(*args, **kwargs)
             File "/tmp/frequenz-sdk-python/.venv/lib/python3.11/site-packages/griffe/mixins.py", line 393, in __call__
               warnings.warn(
WARNING -  mkdocs_autorefs: reference/frequenz/sdk/actor/index.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'
WARNING -  mkdocs_autorefs: reference/frequenz/sdk/actor/index.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'
WARNING -  mkdocs_autorefs: reference/frequenz/sdk/actor/index.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'
WARNING -  mkdocs_autorefs: user-guide/actors.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'
WARNING -  mkdocs_autorefs: user-guide/actors.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'
WARNING -  mkdocs_autorefs: user-guide/actors.md: Could not find cross-reference target '[frequenz.sdk.actor.Actor.__init__]'

Full log with -v attached.

Expected behavior

It picks up the __init__ from the parent class as before.

Environment information

$ griffe --debug-info
- __System__: Linux-6.7.12-amd64-x86_64-with-glibc2.38
- __Python__: cpython 3.11.9 (/tmp/frequenz-sdk-python/.venv/bin/python)
- __Environment variables__:
- __Installed packages__:
  - `griffe` v0.46.0

PASTE OUTPUT HERE

Additional context

Using griffe 0.45.3 works:

$ python -m pip install griffe==0.45.3
Collecting griffe==0.45.3
  Using cached griffe-0.45.3-py3-none-any.whl.metadata (6.3 kB)
Requirement already satisfied: colorama>=0.4 in ./.venv/lib/python3.11/site-packages (from griffe==0.45.3) (0.4.6)
Using cached griffe-0.45.3-py3-none-any.whl (120 kB)
Installing collected packages: griffe
  Attempting uninstall: griffe
    Found existing installation: griffe 0.46.0
    Uninstalling griffe-0.46.0:
      Successfully uninstalled griffe-0.46.0
Successfully installed griffe-0.45.3
$ mkdocs serve
INFO    -  Building documentation...
INFO    -  [macros] - Macros arguments: {'module_name': 'docs/_scripts/macros', 'modules': [], 'render_by_default': True, 'include_dir': '', 'include_yaml': [], 'j2_block_start_string': '', 'j2_block_end_string': '', 'j2_variable_start_string': '', 'j2_variable_end_string': '', 'on_undefined': 'strict',
           'on_error_fail': True, 'verbose': False}
INFO    -  [macros] - Found local Python module 'docs/_scripts/macros' in: /tmp/frequenz-sdk-python
INFO    -  [macros] - Found external Python module 'docs/_scripts/macros' in: /tmp/frequenz-sdk-python
INFO    -  [macros] - Extra variables (config file): ['social', 'version']
INFO    -  [macros] - Extra filters (module): ['pretty']
INFO    -  Cleaning site directory
INFO    -  Doc file 'SUMMARY.md' contains an unrecognized relative link 'user-guide/', it was left as is. Did you mean 'user-guide/index.md'?
INFO    -  Doc file 'SUMMARY.md' contains an unrecognized relative link 'tutorials/', it was left as is.
INFO    -  Doc file 'SUMMARY.md' contains an unrecognized relative link 'reference/', it was left as is.
INFO    -  Doc file 'user-guide/glossary.md' contains a link '#grid_power', but there is no such anchor on this page.
INFO    -  Documentation built in 7.11 seconds
INFO    -  [10:32:53] Watching paths for changes: 'docs', 'mkdocs.yml', 'src', 'CONTRIBUTING.md'
INFO    -  [10:32:53] Serving on http://127.0.0.1:8000/

Metadata

Metadata

Assignees

Labels

unconfirmedThis bug was not reproduced yet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions