Skip to content

Fix inference of IntEnum value attribute type (Python 2) #10417

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 1 commit into from
May 4, 2021

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 4, 2021

The enum stubs for Python 2 are slightly different from Python 3.
The fix in #10412 didn't quite work in Python 2 mode, since IntEnum
doesn't define __new__, and the __new__ from builtins.int is
found instead. Work around this by skipping any __new__ methods
found in built-in types.

I gave up trying to write a test case for this. It's tricky because
enum is in Python 3 stdlib but not in Python 2 stdlib.

The enum stubs for Python 2 are slightly different from Python 3.
The fix in #10412 didn't quite work in Python 2 mode, since `IntEnum`
doesn't define `__new__`, and the `__new__` from `builtins.int` is
found instead. Work around this by skipping any `__new__` methods
found in built-in types.

I gave up trying to write a test case for this. It's tricky because
`enum` is in Python 3 stdlib but not in Python 2 stdlib.
@JukkaL JukkaL merged commit e4bf526 into master May 4, 2021
@JukkaL JukkaL deleted the more-enum-newtype branch May 4, 2021 17:54
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.

2 participants