There a couple of issues with current PEP version wrt. type and doc annotations:
name: Annotated[str, Doc("The user's name")]
— requires type, what if someone only wants a doc? There’s no standaloneDoc
in the PEP.UserName: TypeAlias = Annotated[str, Doc("The user's name")]
— confuses what is being annotated. Arguably, some function argname: UserName
should get doc slapped on it; instead, doc is slapped on an alias.
What would be awesome is being able to express any of the below:
name: "User's preferred personal name"
name: str @ "User's preferred name"
name: "User's preferred name" @ str
name: str
Specifically, have doc decoupled from type by default.
(I’m abusing matrix multiplication operator because as a stand-in for hypothetical syntax that would allow several annotations on a single object)