Putting backwards compatibility aside, I think it would’ve been best to have item-scoped docstring BEFORE each item with slightly modified syntax from normal comments:
#! doc for a type alias
type MyT = str
#! doc for a function
def func(
#! doc for an argument
a: str,
#! this one too
b: int
):
pass
#! doc for a class
#! can be multi lines
class MyClass:
#! doc for a field
field: str
(This is a different topic but if this was synthetically available, it would’ve also been useful for ORM libraries as you can imagine.)