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.
gh-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ #108704
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-108682: [Enum] raise TypeError if super().__new__ called in custom __new__ #108704
Changes from 1 commit
78b9f67
7693241
561dac5
0435142
4e93222
1fbf624
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Is it ok to move
_member_map_
check after_missing_
hook?I have a derived class has no members and hook
_missing_
, it raise exception here.@ethanfurman
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.
Unfortunately, no. I tried to do that, but then the bug wasn't fixed.
What does your
missing()
hook do?If you have no other alternative, you'll need to subclass
EnumType
and override the__call__
method.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.
Thanks for the quick reply. here is an example:
which prints
before this change.
As my understanding, hook
_missing_
handle the missing input, a dynamic value in the above case.so I raise the question: hook
_missing_
before empty check.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'll chime in here as well. I have the same question and got hit by this change as well. We have a setup where we do like:
Previously, Result(0) returned CommonResult.OK. Now throws. It was a nifty pattern to use, and it sort of breaks the combination of using the
_missing_
and subclasses of Enum.