Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support enum.nonmember for python3.11+#17376

Merged
sobolevn merged 2 commits intomasterfrom
issue-12841-nonmember
Jun 14, 2024
Merged

Support enum.nonmember for python3.11+#17376
sobolevn merged 2 commits intomasterfrom
issue-12841-nonmember

Conversation

@sobolevn
Copy link
Copy Markdown
Member

@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a 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.

@sobolevn
Copy link
Copy Markdown
Member Author

sobolevn commented Jun 13, 2024

I will this open for a day, so others can comment.

Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood left a 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!

@sobolevn sobolevn merged commit 3d9256b into master Jun 14, 2024
@sobolevn sobolevn deleted the issue-12841-nonmember branch June 14, 2024 06:10
@sobolevn
Copy link
Copy Markdown
Member Author

Thanks! member will be my next PR, so merging this one.

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants