-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-high
Description
This code generates a false positive, but weirdly I can only reproduce it if the base class is defined in a different module:
from mod import E
class EE(E): # Cannot inherit from final class "E"
X = (0, "")# mod.py
from enum import Enum
from typing import Optional, Type
class E(int, Enum):
def __init__(self, _: int, x: Optional[str] = None) -> None:
self.x = x
def __new__(cls: Type['E'], value: int, x: Optional[str] = None) -> 'E':
enum = int.__new__(cls, value)
enum._value_ = value
enum.x = x
return enumThe code works at runtime.
This started happening as a side effect of #11247.
Marking as high priority, since this is a regression. If it seems clear that this may only happen in pretty specialized circumstances, we can perhaps lower the priority.
cc @sobolevn
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-0-high