KEMBAR78
Fix inference of IntEnum value attribute type (Python 2) by JukkaL · Pull Request #10417 · python/mypy · GitHub
Skip to content

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