Title: bug: `signature_crossrefs` is creating unwanted links when instance attributes set using local variables · Issue #319 · mkdocstrings/python · GitHub
Open Graph Title: bug: `signature_crossrefs` is creating unwanted links when instance attributes set using local variables · Issue #319 · mkdocstrings/python
X Title: bug: `signature_crossrefs` is creating unwanted links when instance attributes set using local variables · Issue #319 · mkdocstrings/python
Description: 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...
Open Graph Description: 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 beco...
X Description: 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 beco...
Opengraph URL: https://github.com/mkdocstrings/python/issues/319
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: `signature_crossrefs` is creating unwanted links when instance attributes set using local variables","articleBody":"### Description of the bug\n\n`signature_crossrefs` is creating links from local variables used to set instance attributes, where the [docs](https://mkdocstrings.github.io/python/usage/configuration/signatures/#signature_crossrefs) say that it should only be doing it for type annotations.\n\nThis becomes a problem if the local variable name matches the name of a heading somewhere else in the docs.\n\n### To Reproduce\n\nSetup:\n\n```bash\npip install mkdocs-material mkdocs-api-autonav\ntouch mkdocs.yml\nmkdir docs\ntouch docs/index.md\nmkdir src\ntouch src/__init__.py\n```\n\n```yml\n# mkdocs.yml\nsite_name: Docs\ntheme:\n name: material\nplugins:\n - autorefs\n - mkdocstrings:\n handlers:\n python:\n options:\n show_if_no_docstring: true\n separate_signature: true\n signature_crossrefs: true\n - api-autonav:\n modules: [\"src\"]\n```\n\n```md\n\u003c!-- docs/index.md --\u003e\n# Intro\n```\n\n```py\n# src/__init__.py\nclass Class:\n def __init__(self):\n intro = \"Some text\"\n self.attr = intro\n```\n\nFinally:\n- run `mkdocs serve`\n- open http://127.0.0.1:8000/reference/src/\n- notice that:\n - `intro` has become a link\n - that link takes you to http://127.0.0.1:8000/#intro, which is unrelated\n\n### Expected behavior\n\nThis link should not have been created.\n\n### Environment information\n\n- __System__: macOS-26.1-arm64-arm-64bit\n- __Python__: cpython 3.12.8 (~/.venv/bin/python)\n- __Environment variables__:\n- __Installed packages__:\n - `mkdocstrings-python` v1.19.0","author":{"url":"https://github.com/hmellor","@type":"Person","name":"hmellor"},"datePublished":"2025-11-15T14:44:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/319/python/issues/319"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1fd1642f-e776-5866-aefc-a10aec9bf094 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EADE:132A0E:8A048EB:B889E47:696E1825 |
| html-safe-nonce | 22fdd248c98bc7c4f6febe393388a5f002cd150502f839af2a8ee0ece66ad138 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQURFOjEzMkEwRTo4QTA0OEVCOkI4ODlFNDc6Njk2RTE4MjUiLCJ2aXNpdG9yX2lkIjoiMTc2ODYyMTUwMDgwMjE0NDI5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 401ef757c39ff8ccf70c82677ea9b615528cdb6b2e782eff49c57fe0372fe868 |
| hovercard-subject-tag | issue:3628797712 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/mkdocstrings/python/319/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e71c881a101dc73fa05ec880febe098e56fd1a93f919e7a6f7f2ae6ea32c587a/mkdocstrings/python/issues/319 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e71c881a101dc73fa05ec880febe098e56fd1a93f919e7a6f7f2ae6ea32c587a/mkdocstrings/python/issues/319 |
| og:image:alt | 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 beco... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hmellor |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a7d6d739bf034e67486b9f97a31887ca30302b72a0acac49b6bcddff34356d7 |
| turbo-cache-control | no-preview |
| go-import | github.com/mkdocstrings/python git https://github.com/mkdocstrings/python.git |
| octolytics-dimension-user_id | 75664361 |
| octolytics-dimension-user_login | mkdocstrings |
| octolytics-dimension-repository_id | 422878404 |
| octolytics-dimension-repository_nwo | mkdocstrings/python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 422878404 |
| octolytics-dimension-repository_network_root_nwo | mkdocstrings/python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 87d7872ec7094ed247923539669aabda9230966f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width