René's URL Explorer Experiment


Title: regression(2.0.9): relative cross-references in re-exported and inherited objects expand against private modules · Issue #346 · mkdocstrings/python · GitHub

Open Graph Title: regression(2.0.9): relative cross-references in re-exported and inherited objects expand against private modules · Issue #346 · mkdocstrings/python

X Title: regression(2.0.9): relative cross-references in re-exported and inherited objects expand against private modules · Issue #346 · mkdocstrings/python

Description: Description of the bug Since 2.0.9, relative cross-references are expanded against the module where an object is defined rather than the path where it's documented. This breaks the very common layout of defining things in private modules...

Open Graph Description: Description of the bug Since 2.0.9, relative cross-references are expanded against the module where an object is defined rather than the path where it's documented. This breaks the very common layo...

X Description: Description of the bug Since 2.0.9, relative cross-references are expanded against the module where an object is defined rather than the path where it's documented. This breaks the very common ...

Opengraph URL: https://github.com/mkdocstrings/python/issues/346

X: @github

direct link

Domain: redirect.github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"regression(2.0.9): relative cross-references in re-exported and inherited objects expand against private modules","articleBody":"### Description of the bug\n\nSince 2.0.9, relative cross-references are expanded against the module where an object is **defined** rather than the path where it's **documented**. This breaks the very common layout of defining things in private modules and re-exporting them from a public one, which used to work fine up to 2.0.8.\n\nThe cause is a9a4ca3 (#342), the fix for #341, which I reported. It anchors the dot-walk on `docstring.parent` whenever it's set. That's what #341 needed for members inherited from another package, but `docstring.parent` is also set for every alias, and there it points at the private defining object. I mentioned that risk at the end of #341, but I didn't realize how common the affected case is, sorry about that.\n\nThere are three variants, all shown by the reproducer below:\n\n1. **A re-exported object**: `pkg.Base` is an alias to `pkg._base.Base`, so `[..Derived]` in its docstring now expands to `pkg._base.Derived` instead of `pkg.Derived`.\n2. **A member of a re-exported class**: `pkg.Base.method` gets `pkg._base.helper` instead of `pkg.helper`.\n3. **An inherited member whose base class is defined in a private module**: `pkg.Derived.method` gets `pkg._base.helper` too.\n\nReferences only keep working when the target happens to be defined in the same private module, because then the expanded canonical path still matches an anchor. That makes the breakage look random from the outside.\n\n### To Reproduce\n\n```bash\nmkdir -p repro/pkg repro/docs\ncd repro\n\ncat > pkg/__init__.py \u003c\u003c'EOF'\n\"\"\"The package.\"\"\"\n\nfrom pkg._base import Base\nfrom pkg._derived import Derived\nfrom pkg._helpers import helper\n\n__all__ = [\"Base\", \"Derived\", \"helper\"]\nEOF\n\ncat > pkg/_helpers.py \u003c\u003c'EOF'\n\"\"\"Private module defining helpers.\"\"\"\n\n\ndef helper() -> None:\n    \"\"\"A helper.\"\"\"\nEOF\n\ncat > pkg/_base.py \u003c\u003c'EOF'\n\"\"\"Private module defining the base class.\"\"\"\n\n\nclass Base:\n    \"\"\"A base class, see also [`Derived`][..Derived].\"\"\"\n\n    def method(self) -> None:\n        \"\"\"A method, see also [`helper`][...helper].\"\"\"\nEOF\n\ncat > pkg/_derived.py \u003c\u003c'EOF'\n\"\"\"Private module defining the derived class.\"\"\"\n\nfrom pkg._base import Base\n\n\nclass Derived(Base):\n    \"\"\"A derived class.\"\"\"\nEOF\n\nprintf '# Package\\n\\n::: pkg\\n' > docs/index.md\n\ncat > mkdocs.yml \u003c\u003c'EOF'\nsite_name: pkg\nstrict: true\nplugins:\n- mkdocstrings:\n    handlers:\n      python:\n        options:\n          inherited_members: true\n          relative_crossrefs: true\nEOF\n\nfor version in 2.0.8 2.0.9; do\n  echo \"### mkdocstrings-python $version\"\n  python -m venv .venv-$version\n  .venv-$version/bin/pip install -q --disable-pip-version-check mkdocs mkdocstrings mkdocstrings-python==$version\n  PYTHONPATH=. .venv-$version/bin/mkdocs build 2>&1 | grep -v '^INFO'\ndone\n```\n\nOutput:\n\n```\n### mkdocstrings-python 2.0.8\n### mkdocstrings-python 2.0.9\nWARNING -  mkdocs_autorefs: index.md: from /tmp/repro/pkg/_base.py:5: (pkg.Base) Could not find cross-reference target 'pkg._base.Derived'\nWARNING -  mkdocs_autorefs: index.md: from /tmp/repro/pkg/_base.py:8: (pkg.Base.method) Could not find cross-reference target 'pkg._base.helper'\nWARNING -  mkdocs_autorefs: index.md: from /tmp/repro/pkg/_base.py:8: (pkg.Derived.method) Could not find cross-reference target 'pkg._base.helper'\n\nAborted with 3 warnings in strict mode!\n```\n\n### Full traceback\n\nThere is no traceback, only the warnings above, which abort the build in strict mode.\n\n### Expected behavior\n\nThe same as in 2.0.8: relative references expand from the path where the object is documented, `pkg.Derived` and `pkg.helper` here.\n\n### Environment information\n\n- __System__: Linux-6.12.111+deb13-amd64-x86_64-with-glibc2.42\n- __Python__: cpython 3.12.14\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 breaks the docs builds of several projects in the [frequenz-floss](https://github.com/frequenz-floss) organization when updating to 2.0.9. For example, frequenz-floss/frequenz-core-python#201 (3 warnings), frequenz-floss/frequenz-channels-python#560 (28), frequenz-floss/frequenz-dispatch-python#306 (6) and frequenz-floss/frequenz-client-common-python#291 (330). All of them build cleanly with 2.0.8.\n\nAbout a fix, I looked into a narrow one first: keeping the new anchor only for inherited aliases (`self.current_object.inherited or not self.current_object.is_alias`). That fixes variants 1 and 2, but not variant 3, which is most of the client-common warnings. For inherited members, the defining object is the right tree but the wrong path whenever the base class lives in a private module, and I couldn't find a reliable way to get its public path. Restricting the new anchor to members inherited from *another package* doesn't work either: `Alias.package` returns the target's package, and namespace packages like `frequenz.*` share the same top module.\n\nSo I'd suggest reverting a9a4ca3 if we don't find a proper fix soon, which brings back the 2.0.8 behavior and with it the cross-package case of #341. That seems like the smaller problem: it only affects relative references in docstrings inherited from another package, ~~it has the workaround discussed in #344,~~ and a proper fix would need the kind of cross-reference rework that, as you said there, is better left to Zensical. This regression, on the other hand, affects the most common package layout. I can send a PR with the revert plus regression tests for the three variants above, if you agree.\n\n","author":{"url":"https://github.com/llucax","@type":"Person","name":"llucax"},"datePublished":"2026-10-02T13:11:12Z","url":"https://github.com/mkdocstrings/python/issues/346"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0a599789-ae47-bd15-b5f4-bd1567873144
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDF40:2536B8:76C843:9CD378:6AF84401
html-safe-nonceeb41604d2d209fe4535ad1ab61f3ced409e51dc25f9e74c620415f4546d14b87
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjQwOjI1MzZCODo3NkM4NDM6OUNEMzc4OjZBRjg0NDAxIiwidmlzaXRvcl9pZCI6Ijg4NTU3MzQ4MDI4NjI3NDU2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2f5ccc3770e6a89d0c04f8590ae8b5abbf970fe6b9a4f2f895286a1535ce1c0e
hovercard-subject-tagissue:5677891277
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/mkdocstrings/python/346/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3ce4c81a39411b9eab50806d04c92d35d0788f1867bb3969e8d6affbfcc98401/mkdocstrings/python/issues/346
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3ce4c81a39411b9eab50806d04c92d35d0788f1867bb3969e8d6affbfcc98401/mkdocstrings/python/issues/346
og:image:altDescription of the bug Since 2.0.9, relative cross-references are expanded against the module where an object is defined rather than the path where it's documented. This breaks the very common layo...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamellucax
hostnamegithub.com
expected-hostnamegithub.com
None5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db
turbo-cache-controlno-preview
go-importgithub.com/mkdocstrings/python git https://github.com/mkdocstrings/python.git
octolytics-dimension-user_id75664361
octolytics-dimension-user_loginmkdocstrings
octolytics-dimension-repository_id422878404
octolytics-dimension-repository_nwomkdocstrings/python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id422878404
octolytics-dimension-repository_network_root_nwomkdocstrings/python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release653be32ff5c755082a4db662491bfbbcfc9112c1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://redirect.github.com/mkdocstrings/python/issues/346#start-of-content
https://redirect.github.com/
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmkdocstrings%2Fpython%2Fissues%2F346
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://redirect.github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmkdocstrings%2Fpython%2Fissues%2F346
Sign uphttps://redirect.github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=mkdocstrings%2Fpython
Reloadhttps://redirect.github.com/mkdocstrings/python/issues/346
Reloadhttps://redirect.github.com/mkdocstrings/python/issues/346
Reloadhttps://redirect.github.com/mkdocstrings/python/issues/346
mkdocstringshttps://redirect.github.com/mkdocstrings
pythonhttps://redirect.github.com/mkdocstrings/python
Codehttps://redirect.github.com/mkdocstrings/python
Issues6 (6)https://redirect.github.com/mkdocstrings/python/issues
Pull requestshttps://redirect.github.com/mkdocstrings/python/pulls
Discussionshttps://redirect.github.com/mkdocstrings/python/discussions
Actionshttps://redirect.github.com/mkdocstrings/python/actions
Security and qualityhttps://redirect.github.com/mkdocstrings/python/security
Insightshttps://redirect.github.com/mkdocstrings/python/pulse
https://redirect.github.com/mkdocstrings/python
New issuehttps://redirect.github.com/login?return_to=https://github.com/mkdocstrings/python/issues/346
New issuehttps://redirect.github.com/login?return_to=https://github.com/mkdocstrings/python/issues/346
regression(2.0.9): relative cross-references in re-exported and inherited objects expand against private moduleshttps://redirect.github.com/mkdocstrings/python/issues/346#top
refactorChange suggestion, not a bug nor a feature.https://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
https://github.com/llucax
llucaxhttps://github.com/llucax
on Oct 2, 2026https://github.com/mkdocstrings/python/issues/346#issue-5677891277
a9a4ca3https://github.com/mkdocstrings/python/commit/a9a4ca3bfd8ee361cd8f7aa63a5079b232adc837
#342https://github.com/mkdocstrings/python/pull/342
#341https://github.com/mkdocstrings/python/issues/341
#341https://github.com/mkdocstrings/python/issues/341
#341https://github.com/mkdocstrings/python/issues/341
frequenz-flosshttps://github.com/frequenz-floss
frequenz-floss/frequenz-core-python#201https://github.com/frequenz-floss/frequenz-core-python/pull/201
frequenz-floss/frequenz-channels-python#560https://github.com/frequenz-floss/frequenz-channels-python/pull/560
frequenz-floss/frequenz-dispatch-python#306https://github.com/frequenz-floss/frequenz-dispatch-python/pull/306
frequenz-floss/frequenz-client-common-python#291https://github.com/frequenz-floss/frequenz-client-common-python/pull/291
a9a4ca3https://github.com/mkdocstrings/python/commit/a9a4ca3bfd8ee361cd8f7aa63a5079b232adc837
#341https://github.com/mkdocstrings/python/issues/341
#344https://github.com/mkdocstrings/python/issues/344
https://redirect.github.com/llucax
llucaxhttps://redirect.github.com/llucax
on Oct 2, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-5953305427
#344https://github.com/mkdocstrings/python/issues/344
#341https://github.com/mkdocstrings/python/issues/341
#341https://github.com/mkdocstrings/python/issues/341
#342https://github.com/mkdocstrings/python/pull/342
llucaxhttps://redirect.github.com/llucax
on Oct 2, 2026https://github.com/mkdocstrings/python/issues/346#event-32336726232
https://redirect.github.com/pawamoy
pawamoyhttps://redirect.github.com/pawamoy
on Oct 9, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-6085564567
@llucaxhttps://github.com/llucax
#342https://github.com/mkdocstrings/python/pull/342
pawamoyhttps://redirect.github.com/pawamoy
unconfirmedThis bug was not reproduced yethttps://redirect.github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22unconfirmed%22
on Oct 9, 2026https://github.com/mkdocstrings/python/issues/346#event-32895100950
https://redirect.github.com/llucax
llucaxhttps://redirect.github.com/llucax
on Oct 12, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-6123555579
https://redirect.github.com/pawamoy
pawamoyhttps://redirect.github.com/pawamoy
on Oct 12, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-6130026639
#342https://github.com/mkdocstrings/python/pull/342
https://redirect.github.com/llucax
llucaxhttps://redirect.github.com/llucax
on Oct 13, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-6140644482
https://redirect.github.com/pawamoy
pawamoyhttps://redirect.github.com/pawamoy
on Oct 17, 2026https://github.com/mkdocstrings/python/issues/346#issuecomment-6233224364
pawamoyhttps://redirect.github.com/pawamoy
refactorChange suggestion, not a bug nor a feature.https://redirect.github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
unconfirmedThis bug was not reproduced yethttps://redirect.github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22unconfirmed%22
on Oct 17, 2026https://github.com/mkdocstrings/python/issues/346#event-33516611628
Sign up for freehttps://redirect.github.com/signup?return_to=https://github.com/mkdocstrings/python/issues/346
Sign in to commenthttps://redirect.github.com/login?return_to=https://github.com/mkdocstrings/python/issues/346
refactorChange suggestion, not a bug nor a feature.https://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.