From a30f2b99c354a6ef0c8a2820c130e68d87912624 Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Sun, 1 Aug 2021 18:53:00 +0100 Subject: [PATCH] Recursively resolve PEP 585 builtins --- sphinx/util/typing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 4450d4edb..bd2a2ad38 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -121,7 +121,10 @@ def restify(cls: Optional[Type]) -> str: else: return ' | '.join(restify(a) for a in cls.__args__) elif cls.__module__ in ('__builtin__', 'builtins'): - return ':class:`%s`' % cls.__name__ + if hasattr(cls, '__args__'): + return ':class:`%s`\\[%s]' % (cls.__name__, ', '.join(restify(arg) for arg in cls.__args__)) + else: + return ':class:`%s`' % cls.__name__ else: if sys.version_info >= (3, 7): # py37+ return _restify_py37(cls)