-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
fix: Don't turn items annotated as InitVar into dataclass members #252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really know nothing about dataclasses haha! Thanks 🙂
I have just accepted them as a Whac-A-Mole situation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, LGTM, lets squash and merge 🙂
Ah wait, there are some linting warnings, let me fix those. |
This change gives the Parameter class the following attributes / propeties: - docstring - lineno - endlineno - parent - lines - linescollections - source Currenlty these values are only populated for dataclasses, and they are None for regular classes and functions. This makes it possible to accesss this information for all dataclass parameters, especially those set as `InitVar` where it was not possible to get it since they are not members (attributes) of the class. Issue mkdocstrings#286: mkdocstrings#286 Related to mkdocstrings#252: mkdocstrings#252
This change gives the Parameter class the `docstring` and `function` attributes. The docstring value is only populated for dataclasses. This makes it possible to access this information for all dataclass parameters, especially those set as `InitVar` where it was not possible to get it since they are not members (attributes) of the class. This slot can also be used to support things like PEP 727 (with extensions). In the future, we might add such a docstring slot to yielded, received and returned values too. Issue-286: #286 Related-to-mkdocstrings/griffe#252: #252 PR-288: #288 Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
This PR addresses the case of dataclass init-only variables also being treated as class members. i.e
is equivalent (compatible) to
The class is not expected to have member
z
(instance.z
).