-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Support enum.nonmember
for python3.11+
#17376
Conversation
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
It's good to have support for additional enum features.
I will this open for a day, so others can 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.
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!
Thanks! |
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 <Alex.Waygood@Gmail.com>
This PR adds support for https://docs.python.org/3.11/library/enum.html#enum.nonmember
Refs #12841