Skip to content
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

Correctly handle Enum name on Python 3.11 #14133

Merged
merged 3 commits into from
Nov 18, 2022

Conversation

ilevkivskyi
Copy link
Member

@ilevkivskyi ilevkivskyi commented Nov 18, 2022

Fixes #12483
Fixes python/typeshed#7564
Ref #12841

The fix is straightforward. I can't use a unit test for this because there are some builtins fixtures that don't have tuple, so I can't do version check.

@github-actions

This comment has been minimized.

Copy link
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.

Looks good, and it's great to have this fixed. This PR also fixes python/typeshed#7564.

There's still the outstanding issue that mypy won't spot that this will raise an AttributeError at runtime on 3.11+:

import enum

class E(enum.Enum):
    X = 1
    @enum.property
    def foo(self) -> int: return 42

assert E.X.foo == 42  # this is fine
E.foo  # AttributeError raised here at runtime

But this is a much lower-priority problem, and can be filed as a follow-up issue.

@github-actions
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(🐞) Enum.name is Any in 3.11 / support enum.property (🐞) Enum.name is Any in 3.11
2 participants