Author eric.smith
Recipients eric.smith, jmg
Date 2020-11-20.15:57:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605887834.66.0.357398005881.issue42414@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-20 15:57:14eric.smithsetrecipients: + eric.smith, jmg
2020-11-20 15:57:14eric.smithsetmessageid: <1605887834.66.0.357398005881.issue42414@roundup.psfhosted.org>
2020-11-20 15:57:14eric.smithlinkissue42414 messages
2020-11-20 15:57:14eric.smithcreate