gh-91507: [dataclasses] preserve the order of __post_init__ kwargs - #107247
Open
szobov wants to merge 3 commits into
Open
gh-91507: [dataclasses] preserve the order of __post_init__ kwargs#107247szobov wants to merge 3 commits into
szobov wants to merge 3 commits into
Conversation
added 3 commits
July 24, 2023 19:53
To test that kw-args are ignored for __post_init__ with InitVar
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
|
The following commit authors need to sign the Contributor License Agreement: |
|
@szobov I’m not at a computer to test. Does this work for a def like: @dataclass
class Foo:
x: InitVar[int]
y: InitVar[int]
def __post_init__(self, my_x, my_y):
print(my_x, my_y) |
Author
|
Hello @ssweber! Here the test I used to test it: Hope it addresses your concerns. |
|
This PR is stale because it has been open for 30 days with no activity. |
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.
Scope
These changes fix the problem described in #91507.
The issue was marked as closed but not solved and contains a very relevant discussion.
In-depth
kwargs, but the order is ignored, and the values are assigned unexpectedly.__init__method to accept*args, **kwargsand move the content of the old implementation to a new__main_init__.Side note
Thanks for any guidance and advice.
I'm free to implement suggestions or close this PR if the proposed solution is unacceptable.
I'll sign CLA right after a review.
Best wishes,
Sergei