Skip to content

bug: signature_crossrefs is creating unwanted links when instance attributes set using local variables#319

@hmellor

Description

@hmellor

Description of the bug

signature_crossrefs is creating links from local variables used to set instance attributes, where the docs say that it should only be doing it for type annotations.

This becomes a problem if the local variable name matches the name of a heading somewhere else in the docs.

To Reproduce

Setup:

pip install mkdocs-material mkdocs-api-autonav touch mkdocs.yml mkdir docs touch docs/index.md mkdir src touch src/__init__.py
# mkdocs.ymlsite_name: Docstheme: name: materialplugins: - autorefs - mkdocstrings: handlers: python: options: show_if_no_docstring: trueseparate_signature: truesignature_crossrefs: true - api-autonav: modules: ["src"]
<!-- docs/index.md --># Intro
# src/__init__.pyclassClass: def__init__(self): intro="Some text"self.attr=intro

Finally:

Expected behavior

This link should not have been created.

Environment information

  • System: macOS-26.1-arm64-arm-64bit
  • Python: cpython 3.12.8 (~/.venv/bin/python)
  • Environment variables:
  • Installed packages:
    • mkdocstrings-python v1.19.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions