-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add _generate_next_value_ to StrEnum
#10390
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
Merged
Merged
Conversation
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
This change is enough to (at least partially) fix #10384 Why? Because `mypy` already had this plugin in place: https://github.com/python/mypy/blob/b995e1620789a3ab2fc5dbcf0698a9077b0f5731/mypy/plugins/enums.py#L85-L90 So, adding it locally produces: ```python from enum import StrEnum, auto class A(StrEnum): a = auto() reveal_type(type(A.a)) # N: Revealed type is "Type[Literal[ex.A.a]?]" reveal_type(type(A.a.value)) # N: Revealed type is "Type[builtins.str]" ``` Closes #10384
_generate_next_value to StrEnum_generate_next_value_ to StrEnum
AlexWaygood
reviewed
Jun 30, 2023
sobolevn
commented
Jun 30, 2023
JelleZijlstra
approved these changes
Jun 30, 2023
AlexWaygood
reviewed
Jun 30, 2023
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood
approved these changes
Jun 30, 2023
Member
AlexWaygood
left a comment
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!
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
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 change is enough to (at least partially) fix #10384
Why? Because
mypyalready had this plugin in place: https://github.com/python/mypy/blob/b995e1620789a3ab2fc5dbcf0698a9077b0f5731/mypy/plugins/enums.py#L85-L90Source: https://github.com/python/cpython/blob/319de0b578ec3dec8d30610caee3aa93f51060c7/Lib/enum.py#L1279
So, adding it locally produces:
Closes #10384