-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
gh-89398: Fix argparse namespace overridden by subparsers default #30219
base: main
Are you sure you want to change the base?
gh-89398: Fix argparse namespace overridden by subparsers default #30219
Conversation
def _get_kwargs(self): | ||
kwargs = self.__defaults__ | self.__dict__ | ||
kwargs.pop('__defaults__', None) | ||
return list(kwargs.items()) |
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.
Why do you convert it into a list if the caller (__eq__
) turns it into a dict again?
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.
The __repr__
implementation of the parent class _AttributeHolder
also calls this. But this change can be considered.
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.
Ah right, I should have checked that. Better to just leave it as is then.
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.
Test module shows no issues in 1674 tests.
2281bfe
to
4c5cc3c
Compare
4c5cc3c
to
95cb850
Compare
This PR is to fix gh-89398 with another approach than #29574.
The default values are stored in a dunder attribute in
Namespace
to ensure they don't override the given values.