My code (reduced to just a few lines for this demo) looks like this:
AgentAssignment = List[int]
def assignment2str(assignment: AgentAssignment):
pass
The produced html documentation has List[int] as the type hint. This seems to be a resolved issue (#6518), but I am still running into it in 2022 with Sphinx version 5.1.1 (and Python 3.8.2). What am I missing?
So, one needs to add at the beginning of the file (yes, before all other imports):
from __future__ import annotations
Then in conf.py:
autodoc_type_aliases = {'AgentAssignment': 'AgentAssignment'}
Not that this identity-transformation dictionary makes any sense to me, but it did the trick...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With