mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add support for PEP 585 generics
This commit is contained in:
parent
810a1e2988
commit
31e07c75dd
@ -310,6 +310,8 @@ def stringify(annotation: Any) -> str:
|
|||||||
return INVALID_BUILTIN_CLASSES[annotation]
|
return INVALID_BUILTIN_CLASSES[annotation]
|
||||||
elif (getattr(annotation, '__module__', None) == 'builtins' and
|
elif (getattr(annotation, '__module__', None) == 'builtins' and
|
||||||
hasattr(annotation, '__qualname__')):
|
hasattr(annotation, '__qualname__')):
|
||||||
|
if hasattr(annotation, '__args__'): # PEP 585 generic
|
||||||
|
return repr(annotation)
|
||||||
return annotation.__qualname__
|
return annotation.__qualname__
|
||||||
elif annotation is Ellipsis:
|
elif annotation is Ellipsis:
|
||||||
return '...'
|
return '...'
|
||||||
|
Loading…
Reference in New Issue
Block a user