-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Milestone
Description
Describe the bug
If you use a PEP 585 generic as an annotation i.e. list[str], autodoc renders the annotation as list rather than list[str], this behaviour differs from using typing.List[str] which renders as expected.
Fixing this is quite simple as far as I can tell,
Lines 311 to 313 in 810a1e2
| elif (getattr(annotation, '__module__', None) == 'builtins' and | |
| hasattr(annotation, '__qualname__')): | |
| return annotation.__qualname__ |
__args__ and if it does, return repr(annotation)
How to Reproduce
def foo() -> list[str]:
..... autofunction:: fooExpected behavior
An annotation of list[str] to be rendered as list[str]
Your project
https://github.com/Gobot1234/sphinx-test
Screenshots
OS
Mac
Python version
Python 3.9.3
Sphinx version
4.1.1
Sphinx extensions
autodoc
Extra tools
No response
Additional context
No response
