-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Support field docstrings for dataclasses that use __slots__ #113878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think this change is okay. I don't think it would be reasonable for anyone to assume that dataclasses' That said, the documentation at https://docs.python.org/3/reference/datamodel.html says of |
It would be nice to have the dict case specifically called out in the data model docs. Right now, all we have is the announcement in the 3.8 whatsnew. |
Created #114044 for the documentation issue. |
One question I have about this feature: should it be an error to specify |
I think it should be ok, some other tool might also use this
As a separate feature, I guess :) |
That makes sense to me. In this regard, it would be a bit like the metadata field but for a dedicated purpose. |
I'm not sure this answers your question, @sobolevn, but: I mean that I'll grant you that this is an unrelated issue. |
My typical questions when adding a feature to dataclasses are:
|
I don't think
It does not impact |
Hi, is there any update on this? I am working on a configuration module that needs to be able to read default values from the dataclass and I'd like to be able to set the docstring for the field as well. |
I am waiting on @ericvsmith's review :) |
If using `slots=True`, the `doc` parameter ends up in the `__slots__` dict. The `doc` parameter is also in the corresponding `Field` object.
…ation (pythonGH-134065) (cherry picked from commit 9d73875) Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Feature or enhancement
Proposal:
A really nice
__slots__
feature is the ability to provide a data dictionary in the form of docstrings. That is also available forproperty
objects. Consider this example:Running
help(Rocket)
shows all the field docstrings which is super helpful:It would be nice is the same can be done with dataclasses that define
__slots__
:Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
doc
parameter todataclasses.field
#114051dataclasses.field()
documentation #134065versionadded
indataclasses.field()
documentation (GH-134065) #134128The text was updated successfully, but these errors were encountered: