8000 IntEnum with NewType value type regression · Issue #10411 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

IntEnum with NewType value type regression #10411

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

Closed
JukkaL opened this issue May 4, 2021 · 1 comment · Fixed by #10412
Closed

IntEnum with NewType value type regression #10411

JukkaL opened this issue May 4, 2021 · 1 comment · Fixed by #10412
Assignees
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high

Comments

@JukkaL
Copy link
Collaborator
JukkaL commented May 4, 2021

The type of E.A.value in this program has changed since the last release:

from typing import NewType
from enum import IntEnum

N = NewType("N", int)

class E(IntEnum):
    A = N(0)

# mypy 0.812: N
# master:     int
reveal_type(E.A.value)

The original inferred type N is more precise, so this looks like a regression. This causes false positives with mypy-protobuf.

@JukkaL JukkaL added bug mypy got something wrong priority-0-high false-positive mypy gave an error on correct code labels May 4, 2021
@JukkaL JukkaL self-assigned this May 4, 2021
@JukkaL
Copy link
Collaborator Author
JukkaL commented May 4, 2021

This was introduced in #10057.

JukkaL added a commit that referenced this issue May 4, 2021
If the enum value initializer has a NewType type, it should be
reflected in the type of the `value` attribute. It was broken because
the special casing for `__new__` introduced in #10057 didn't consider
the `__new__` in `IntEnum` as special.

Fixes #10411.
JukkaL added a commit that referenced this issue May 4, 2021
If the enum value initializer has a NewType type, it should be
reflected in the type of the `value` attribute. It was broken because
the special casing for `__new__` introduced in #10057 didn't consider
the `__new__` in `IntEnum` as special.

Fixes #10411.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code priority-0-high
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0