Add support for PEP 585 generics

This commit is contained in:
James
2021-07-17 17:57:00 +01:00
committed by GitHub
parent 810a1e2988
commit 31e07c75dd

View File

@@ -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 '...'