Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Release 9.1.1 (in development)
Bugs fixed
----------

* #14653: autodoc: Render enum members in ``Annotated`` metadata the same way
as ``Literal`` arguments, instead of dumping ``repr()``.
Patch by Gyanu

* #14465: LaTeX: PDF build crash since LaTeX June 2026 release if tables are
styled with ``'colorrows'`` (which is the default).
Patch by Jean-François B.
Expand Down
4 changes: 2 additions & 2 deletions sphinx/util/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def restify(cls: Any, mode: _RestifyMode = 'fully-qualified-except-typing') -> s
])
meta_args.append(rf'{restify(type(m), mode)}\ ({d_fields})')
else:
meta_args.append(repr(m))
meta_args.append(_format_literal_arg_restify(m, mode=mode))
meta = ', '.join(meta_args)
return (
f':py:class:`{module_prefix}{cls.__module__}.{cls.__name__}`'
Expand Down Expand Up @@ -594,7 +594,7 @@ def stringify_annotation(
f'{stringify_annotation(type(m), mode=mode, short_literals=short_literals)}({d_fields})' # NoQA: E501
)
else:
meta_args.append(repr(m))
meta_args.append(_format_literal_arg_stringify(m, mode=mode))
meta = ', '.join(meta_args)
return f'{module_prefix}Annotated[{args}, {meta}]'
elif all(is_system_TypeVar(a) for a in annotation_args):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_util/test_util_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ def test_restify_Annotated() -> None:
assert ann_rst == (
':py:class:`~typing.Annotated`\\ [:py:class:`float`, :py:class:`~tests.test_util.test_util_typing.Gt`\\ (gt=\\ -10.0)]'
)
ann_rst = restify(Annotated[int, MyEnum.a], 'fully-qualified-except-typing')
assert ann_rst == (
':py:class:`~typing.Annotated`\\ [:py:class:`int`, :py:attr:`tests.test_util.test_util_typing.MyEnum.a`]'
)
ann_rst = restify(Annotated[int, MyEnum.a], 'smart')
assert ann_rst == (
':py:class:`~typing.Annotated`\\ [:py:class:`int`, :py:attr:`~tests.test_util.test_util_typing.MyEnum.a`]'
)


def test_restify_type_hints_Callable() -> None:
Expand Down Expand Up @@ -730,6 +738,12 @@ def test_stringify_Annotated() -> None:
assert ann_str == (
'~typing.Annotated[float, ~tests.test_util.test_util_typing.Gt(gt=-10.0)]'
)
ann_str = stringify_annotation(
Annotated[int, MyEnum.a], 'fully-qualified-except-typing'
)
assert ann_str == 'Annotated[int, tests.test_util.test_util_typing.MyEnum.a]'
ann_str = stringify_annotation(Annotated[int, MyEnum.a], 'smart')
assert ann_str == '~typing.Annotated[int, MyEnum.a]'


def test_stringify_Unpack() -> None:
Expand Down
Loading