From 31e07c75dd235f30d70760f8d0181364b466a7ef Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Sat, 17 Jul 2021 17:57:00 +0100 Subject: [PATCH] Add support for PEP 585 generics --- sphinx/util/typing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 4e1b184e0..5c72d6f32 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -310,6 +310,8 @@ def stringify(annotation: Any) -> str: return INVALID_BUILTIN_CLASSES[annotation] elif (getattr(annotation, '__module__', None) == 'builtins' and hasattr(annotation, '__qualname__')): + if hasattr(annotation, '__args__'): # PEP 585 generic + return repr(annotation) return annotation.__qualname__ elif annotation is Ellipsis: return '...'