Quick, personal summary, with new thoughts:
-
Counter-argument: âitâs not typingâ.
Annotated
was designed to annotate types, true, but also says:As such,
Annotated
can be useful for code that wants to use annotations for purposes outside Pythonâs static typing system.Unfortunately the
typing
module is the only meaningful location in the standard library forDoc
(next toAnnotated
). There isnât a generic documentation-related standard module(maybe we could create one
?). Even if many do not use or consider typing primarily as documentation, it is still also documentation.
-
Counter-argument: âitâs too verboseâ. Not really. Spacing taken aside, you can alias
Annotated
asA
, thenA[int, Doc("string")]
is ~10 characters more thanint
, for each documented parameter. But from that we could substract the average length of parameter names, since we donât have to repeat them in function/class docstrings. -
Counter-argument: âit makes big signaturesâ. Big signatures can be collapsed (partly or completely) with adequate tooling. Even without
Doc
, signatures with annotated types can grow quite big, so it would make sense to me that IDEs and text editors would allow collapsing each parameter in signatures, maybe just showing the (truncated) unannotated type and (truncated) default value. -
Counter-argument: âitâs not pretty or as pretty as function docstringsâ. Personal preference
-
Counter-argument: âaccepting it in the stdlib puts pressure on the ecosystem to adopt itâ. Recent thought I had: True, but the opposite is true too. By not providing a standard way to structure docs data, pressure is put on the ecosystem to rely on non-standard, divergent, unspecified and sub-optimal docstring styles.
Anyway, I hope Iâm not starting a debate over again Iâm actually happy if
Doc
lives in a third-party library Just wanted to share my perspective again as someone who works a lot with docstring styles (and grows to enjoy them less and less). I hope we can continue working and discussing towards a standard solution even after this PEP is withdrawn or rejected