Skip to content

Show enum members in Annotated types like Literal does - #14654

Open
gyanu2507 wants to merge 2 commits into
sphinx-doc:masterfrom
gyanu2507:annotated-enum-display
Open

Show enum members in Annotated types like Literal does#14654
gyanu2507 wants to merge 2 commits into
sphinx-doc:masterfrom
gyanu2507:annotated-enum-display

Conversation

@gyanu2507

Copy link
Copy Markdown

Annotated[int, Color.red] was going through repr(), so autodoc printed <Color.red: 'red'>. Literal already formats enum members as :py:attr: links — reused that for Annotated metadata.

Fixes #14653

repr() was dumping things like <Color.red: 'red'> into the docs.
@gyanu2507

Copy link
Copy Markdown
Author

The red CI here isn't from this change — it's Pygments 2.21.0, which stopped escaping " as &quot; in its HTML output.

Six tests fail, all of them string-comparing highlighted HTML:

  • test_highlighting.py::test_default_highlight
  • test_builders/test_build_html_code.py::test_html_code_role
  • test_extensions/test_ext_viewcode.py::test_viewcode
  • test_extensions/test_ext_viewcode.py::test_viewcode_linenos
  • test_intl/test_intl.py::test_additional_targets_should_be_translated
  • test_intl/test_intl.py::test_additional_targets_should_not_be_translated

None of them touch sphinx/util/typing.py. To confirm, I checked out this PR's branch point (e44a40e, unmodified master) with Pygments 2.21.0 pinned and got the identical six failures; pinning back to 2.19.2 makes both the branch point and this branch fully green. e44a40e's own CI run was green because it predates the 2.21.0 release on 2026-08-17.

Happy to send the escaping updates as a separate PR if that's useful, or rebase this one once that's sorted — just say which you'd prefer.

No code change. The previous CI run predates recent master activity;
re-trigger to see whether the Pygments HTML escaping failures are still
present on tip.
@gyanu2507

Copy link
Copy Markdown
Author

Pushed an empty commit to re-run CI on current master.

The earlier red jobs were highlighting tests that assert HTML containing &quot; (e.g. test_html_code_role, test_viewcode, test_default_highlight). That tracks Pygments output escaping, not the Annotated-enum formatting change in this PR. If tip is still red the same way, it is a base-branch / dependency issue rather than this diff.

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.

Bad display of annotated enum members

1 participant