![](https://secure.gravatar.com/avatar/9ea64fa01ed0d8529e4ae1b8873bb930.jpg?s=120&d=mm&r=g)
Could this be a use case for typing.Annotated? In [6]: from dataclasses import dataclass In [7]: from typing import Annotated In [8]: class A: ...: """Docstring for class A.""" ...: x: Annotated[int, "Docstring for x"] ...: y: Annotated[bool, "Docstring for y"] = True In [9]: A.__annotations__ Out[9]: {'x': typing.Annotated[int, 'Docstring for x'], 'y': typing.Annotated[bool, 'Docstring for y']} The syntax is a bit arduous; I'd be in favor of thinking through ways to make it easier to write. But the basic functionality already exists; there's no reason to duplicate it with another language feature. Rick. --- Ricky. "I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler On Thu, Nov 18, 2021 at 5:50 AM <tmkehrenberg@gmail.com> wrote:
Stephen J. Turnbull wrote:
@standard_class_docstring_parser class A: """ Class docstring. x: Docstring for x y: Docstring for y """ x: int y: bool = True
Oh, this is actually a nice idea. You could have a decorator that parses reST and then according to some conventions extracts the attribute docstrings. I think I will try to write something like that.
Thomas _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/F2QJ3Q... Code of Conduct: http://python.org/psf/codeofconduct/