Skip to content

FIX: resolve attribute cross-links in the class scope first - #706

Open
lazerg wants to merge 1 commit into
numpy:mainfrom
lazerg:fix-attribute-link-scope
Open

FIX: resolve attribute cross-links in the class scope first#706
lazerg wants to merge 1 commit into
numpy:mainfrom
lazerg:fix-attribute-link-scope

Conversation

@lazerg

@lazerg lazerg commented Sep 7, 2026

Copy link
Copy Markdown

On a class page numpydoc renders every entry of the Attributes list as :obj:`name <name>` . Sphinx resolves that
target against the current module before the current class, so an attribute whose name is also a module-level object
links to the wrong page. On the numpy.ufunc page the identity attribute links to the numpy.identity function
instead of numpy.ufunc.identity, and it has been doing that since at least numpy 1.20.

Prefixing the target with a dot makes the reference specific, so Sphinx tries the class scope first and falls back to
the module scope exactly as before when the attribute is not documented itself.

Reported in numpy/numpy#32532.

@larsoner

larsoner commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Seems totally reasonable (and I had no idea about this "." behavior!). Would it be possible to add some test that fails on main but passes on this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants