You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Readability of API documentation with type annotations #8405
changed the title [-]Readability of API docstrings with type annotations[/-][+]Readability of API documentation with type annotations[/+]on Mar 5, 2021
You're using the Sphinx autodoc extension, add autodoc_typehints = "description" to docs/conf.py to get the hints next to the parameter/return descriptions instead of in the signature.
Tangential: optional[union] doesn't make sense anyway, just add None to the union. That's what happens in runtime anyway iirc
I myself at least prefer to use Optional when the None is just some dummy default/disable value, and Union[..., None] when the None is an actual "legitimate" value (e.g. JsonPrimitive = Union[str, float, bool, None]). Although the new | syntax will make this moot.
Speaking of |, it would also make this a little clearer display wise. Maybe Sphinx can swap Union with | already somehow.
Hey folks,
Recently on twitter a thread about type annotations in documentation gained traction, using pytest as an example:
I'm opening this to see if we can improve the situation.