Skip to content

Docs: :deco: references with ~ render as @~module.name #159265

Open

Description

@graingert

Documentation

Decorator cross-references written with the tilde short form, e.g. :deco:`~typing.dataclass_transform` , render literally as @~typing.dataclass_transform instead of @dataclass_transform. The link target is correct; only the title is wrong.

See e.g. What's New In Python 3.11 – PEP 681.

Cause

The deco role is Sphinx's own (_PyDecoXRefRole). In Sphinx 8.2.3, it prepends @ in update_title_and_target(), which runs before PyXRefRole.process_link(). process_link() then checks title[0:1] == '~', sees @, and leaves the tilde and module prefix in place. Sphinx 9.x prepends the @ in process_link() after the tilde handling, so it renders correctly.

These references were introduced in gh-139598 (gh-105812). That landed while Doc/requirements.txt was pinned to sphinx<9.0.0 (gh-143284, to work around Chinese search in Sphinx 9), so the docs build hits the Sphinx 8 bug.

Possible fixes

  1. Unpin and go back to Sphinx 9 once the Documentation can't find anything in Chinese language #143284 search issue is resolved. That fixes every instance with no .rst changes.
  2. Rewrite each reference with an explicit title, e.g. :deco:`dataclass_transform <typing.dataclass_transform>` , or drop the ~ (:deco:`typing.dataclass_transform` ).

Affected references (29)

Source links are pinned to 0768eed. "Rendered" links point to docs.python.org/dev/ and use a text fragment to jump to the broken text.

Target Source Docs
dataclasses.dataclass howto/enum.rst:512 rendered
functools.total_ordering howto/sorting.rst:375 rendered
contextlib.contextmanager library/contextlib.rst:104 rendered
enum.property library/enum.rst:118 rendered
abc.abstractmethod library/functools.rst:712 rendered
typing.overload library/warnings.rst:614 rendered
functools.total_ordering reference/expressions.rst:2237 rendered
contextlib.contextmanager whatsnew/2.5.rst:748 rendered
contextlib.contextmanager whatsnew/2.6.rst:434 rendered
abc.abstractmethod whatsnew/2.6.rst:1277 rendered
property.getter whatsnew/2.6.rst:1561 rendered
property.setter whatsnew/2.6.rst:1562 rendered
property.deleter whatsnew/2.6.rst:1562 rendered
functools.total_ordering whatsnew/2.7.rst:1270 rendered
functools.total_ordering whatsnew/3.2.rst:812 rendered
abc.abstractclassmethod whatsnew/3.2.rst:1100 rendered
abc.abstractstaticmethod whatsnew/3.2.rst:1101 rendered
reprlib.recursive_repr whatsnew/3.2.rst:1158 rendered
contextlib.contextmanager whatsnew/3.2.rst:1244 rendered
contextlib.contextmanager whatsnew/3.2.rst:1256 rendered
functools.singledispatch whatsnew/3.4.rst:861 rendered
functools.total_ordering whatsnew/3.4.rst:873 rendered
functools.lru_cache whatsnew/3.5.rst:1151 rendered
dataclasses.dataclass whatsnew/3.7.rst:574 rendered
contextlib.asynccontextmanager whatsnew/3.7.rst:833 rendered
typing.runtime_checkable whatsnew/3.10.rst:1488 rendered
typing.dataclass_transform whatsnew/3.11.rst:391 rendered
enum.property whatsnew/3.11.rst:689 rendered
functools.cached_property whatsnew/3.12.rst:1752 rendered

Found with: git grep -n ':deco:`~' -- Doc

Activity

  1. Marwan-verse commented on Oct 12, 2026

    @Marwan-verse

    I opened #159270 with explicit decorator display titles for all 29 affected references across 17 documentation files. This keeps the intended short names while avoiding the Sphinx 8 @~module.name rendering bug. AI disclosure: prepared with OpenAI Codex. I have not run the documentation build locally; CI is checking it.

  2. StanFromIreland commented on Oct 12, 2026

    @StanFromIreland
    Member

    I’m not really sure we need to do anything, most fixes would largely introduce churn, for an issue that doesn’t seem particularly important. The references still work, so I suggest we wait till the next Sphinx release?

    This was also previously reported at #140220.

  3. graingert commented on Oct 13, 2026

    @graingert
    ContributorAuthor

    The fix looks like it's released, but python is pinned to an older release

  4. StanFromIreland commented on Oct 13, 2026

    @StanFromIreland
    Member

    Sorry I meant a fixed release we can use.

  5. graingert commented on Oct 13, 2026

    @graingert
    ContributorAuthor

    Do you know what's blocking the upgrade?

  6. StanFromIreland commented on Oct 13, 2026

    @StanFromIreland
    Member

    No active maintainers have permissions to create a release IIUC.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions