Eric V. Smith <e...@trueblade.com> added the comment:
How would you expect to extract this docstring? I'm not sure how this would work in practice, since both of these are errors: >>> class A: ... def __init__(self): ... self.x = 3 ... self.x.__doc__ = 'foo' ... >>> A() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 4, in __init__ AttributeError: 'int' object attribute '__doc__' is read-only >>> class B: ... x: int = 0 ... x.__doc__ = 'foo' ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in B AttributeError: 'int' object attribute '__doc__' is read-only It could be stored in the dataclass-specific data attached to a class, but then you'd have to use a dataclass-specific function to get access to it. I'm not sure that's a great improvement. I also note that attrs doesn't have this feature, probably for the same reason. ---------- type: -> enhancement versions: +Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42414> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com