Support enum.nonmember for python3.11+#17376
Merged
Conversation
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
approved these changes
Jun 13, 2024
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
It's good to have support for additional enum features.
Member
Author
|
I will this open for a day, so others can comment. |
AlexWaygood
approved these changes
Jun 13, 2024
Member
There was a problem hiding this comment.
LGTM. We could also add some similar special casing for this decorator's twin, enum.member -- currently mypy just follows the typeshed stubs, which leads to incorrect results: https://mypy-play.net/?mypy=latest&python=3.12&gist=1f3799c9117af6d8a55552e4018f526d
I'm also fine with that being done as a followup, if you prefer, though!
Member
Author
|
Thanks! |
JukkaL
pushed a commit
that referenced
this pull request
Jun 14, 2024
There are no tests for `@enum.member` used as a decorator, because I can only decorate classes and functions, which are not supported right now: https://mypy-play.net/?mypy=latest&python=3.12&gist=449ee8c12eba9f807cfc7832f1ea2c49 ```python import enum class A(enum.Enum): class x: ... reveal_type(A.x) # Revealed type is "def () -> __main__.A.x" ``` This issue is separate and rather complex, so I would prefer to solve it independently. Refs #17376 --------- Co-authored-by: Alex Waygood <[email protected]>
5 tasks
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 adds support for https://docs.python.org/3.11/library/enum.html#enum.nonmember
Refs #12841