fix: Don't turn items annotated as InitVar into dataclass members#252
Merged
pawamoy merged 3 commits intomkdocstrings:mainfrom Mar 12, 2024
Merged
fix: Don't turn items annotated as InitVar into dataclass members#252pawamoy merged 3 commits intomkdocstrings:mainfrom
pawamoy merged 3 commits intomkdocstrings:mainfrom
Conversation
pawamoy
reviewed
Mar 12, 2024
Member
pawamoy
left a comment
There was a problem hiding this comment.
I really know nothing about dataclasses haha! Thanks 🙂
Contributor
Author
I have just accepted them as a Whac-A-Mole situation. |
pawamoy
reviewed
Mar 12, 2024
pawamoy
approved these changes
Mar 12, 2024
Member
pawamoy
left a comment
There was a problem hiding this comment.
OK, LGTM, lets squash and merge 🙂
Member
|
Ah wait, there are some linting warnings, let me fix those. |
has2k1
added a commit
to has2k1/griffe
that referenced
this pull request
Jun 10, 2024
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
pawamoy
added a commit
that referenced
this pull request
Jun 12, 2024
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 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).