Title: bug: relative cross-references in inherited members still depend on the consumer's `relative_crossrefs` setting · Issue #345 · mkdocstrings/python · GitHub
Open Graph Title: bug: relative cross-references in inherited members still depend on the consumer's `relative_crossrefs` setting · Issue #345 · mkdocstrings/python
X Title: bug: relative cross-references in inherited members still depend on the consumer's `relative_crossrefs` setting · Issue #345 · mkdocstrings/python
Description: Description of the bug #342 (released in 2.0.9) fixed half of #341: relative cross-references in inherited members now expand against the object the docstring was written on, instead of the inheriting class. The other half is still there...
Open Graph Description: Description of the bug #342 (released in 2.0.9) fixed half of #341: relative cross-references in inherited members now expand against the object the docstring was written on, instead of the inherit...
X Description: Description of the bug #342 (released in 2.0.9) fixed half of #341: relative cross-references in inherited members now expand against the object the docstring was written on, instead of the inherit...
Opengraph URL: https://github.com/mkdocstrings/python/issues/345
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: relative cross-references in inherited members still depend on the consumer's `relative_crossrefs` setting","articleBody":"### Description of the bug\n\n#342 (released in 2.0.9) fixed half of #341: relative cross-references in inherited members now expand against the object the docstring was written on, instead of the inheriting class. The other half is still there. The expansion is still [gated on the consumer's own `relative_crossrefs` setting](https://github.com/mkdocstrings/python/blob/c888dc294f4c8305479d358e976fd8cbb2e0c62c/src/mkdocstrings_handlers/python/_internal/rendering.py#L808), so when a package without that option renders an inherited member whose docstring comes from a dependency that uses relative cross-references, the raw dotted identifier is still handed to autorefs and a strict build fails. #342 left this out of scope explicitly, but #341 was closed as fixed, so I'm opening this to keep track of it.\n\nThis means the consumer's configuration still decides whether a dependency's docstrings resolve. A library author can't tell whether all their downstream users enabled `relative_crossrefs`, and a downstream user shouldn't have to adopt a docstring style just because a base class they inherit from uses it.\n\n### To Reproduce\n\nThe reproducer in #341 still applies unchanged. With `mkdocstrings-python==2.0.9`, its case 2 (`pkgb` built without `relative_crossrefs`) fails exactly as before:\n\n```\n### 2. pkgb's docs, without relative_crossrefs: the raw dotted string leaks\nWARNING - mkdocs_autorefs: index.md: from /path/to/repro/pkga/sub.py:10: (pkgb.Derived.MAPPING) Could not find cross-reference target '....Thing'\n\nAborted with 1 warnings in strict mode!\n```\n\nCase 3 now expands to `pkga.Thing`, which is correct. In that toy setup it still fails in strict mode, but only because `docs-b` neither renders `pkga` nor loads an inventory for it, so that part is expected and not a bug.\n\n### Full traceback\n\nNo traceback, only the `mkdocs_autorefs` warning above, which aborts the build in strict mode.\n\n### Expected behavior\n\nA leading-dot identifier written in a docstring should be expanded whether or not the package rendering it enabled `relative_crossrefs`, at least when the docstring was written on an object other than the one being rendered (as is the case for inherited members). As far as I can tell, an identifier starting with a dot can never resolve as an absolute one, so expanding it wouldn't break any reference that works today.\n\n### Environment information\n\n- __System__: Linux-6.12.107+deb13-amd64-x86_64-with-glibc2.42\n- __Python__: cpython 3.12.14\n- __Environment variables__:\n- __Installed packages__:\n - `mkdocs` v1.6.1\n - `mkdocstrings` v1.0.6\n - `mkdocstrings-python` v2.0.9\n - `mkdocs-autorefs` v1.4.4\n - `griffelib` v2.3.0\n\n### Additional context\n\nThis is the same real-world case described in #341. [frequenz-quantities](https://github.com/frequenz-floss/frequenz-quantities-python) had to turn the relative cross-references in `frequenz.quantities.experimental.marshmallow` into absolute ones (frequenz-floss/frequenz-quantities-python#170), because [frequenz-sdk-python](https://github.com/frequenz-floss/frequenz-sdk-python) subclasses `QuantitySchema` and builds its docs with `inherited_members: true` and `strict: true`, but [without `relative_crossrefs`](https://github.com/frequenz-floss/frequenz-sdk-python/blob/8616b9ac2a40a3c41f2a824aaa79e108e3edcf35/mkdocs.yml#L105-L116). With 2.0.9 we wanted to restore the relative references, but after reverting that change locally, the SDK docs still fail with 2.0.9 unless the SDK also enables `relative_crossrefs`:\n\n```\nWARNING - mkdocs_autorefs: reference/frequenz/sdk/config/index.md: from .../frequenz/quantities/experimental/marshmallow.py:330: (frequenz.sdk.config.BaseConfigSchema.TYPE_MAPPING) Could not find cross-reference target '.....Quantity'\n```\n\nWith `relative_crossrefs: true` in the SDK, 2.0.9 builds cleanly and links to `frequenz.quantities.Quantity` through the quantities inventory, so the #342 fix itself works as intended.\n","author":{"url":"https://github.com/llucax","@type":"Person","name":"llucax"},"datePublished":"2026-09-24T07:55:31Z","url":"https://github.com/mkdocstrings/python/issues/345"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:d12243b2-18fb-fca0-1052-97c857abe5e0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BFAA:8C112:73CFCE:98FCD8:6AF84428 |
| html-safe-nonce | d4db1e49849d5c2e3d4cc1dac2f8cbc7fb081e1d76e4c619c5383777d8428b19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkFBOjhDMTEyOjczQ0ZDRTo5OEZDRDg6NkFGODQ0MjgiLCJ2aXNpdG9yX2lkIjoiMzk1NzY2NTk0OTYyMzUzNDYzMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b65084069ecfdd16606744f45d0b58b2bb9ae06b12442be9e3e490d70130623d |
| hovercard-subject-tag | issue:5565118731 |
| 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/345/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df9a17b3441fb290750d91b5f73439ad2a2876190554bc0fba295fda6132576c/mkdocstrings/python/issues/345 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df9a17b3441fb290750d91b5f73439ad2a2876190554bc0fba295fda6132576c/mkdocstrings/python/issues/345 |
| og:image:alt | Description of the bug #342 (released in 2.0.9) fixed half of #341: relative cross-references in inherited members now expand against the object the docstring was written on, instead of the inherit... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | llucax |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| 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 | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width