-
-
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-1-normal
Description
Example:
from typing import *
TypeT = TypeVar("TypeT", bound=type)
class Base:
field: str = "Hey"
class C1:
def method(self, other: type) -> str:
if issubclass(other, Base):
# reveal_type(other) == Type[Base]
return other.field
return "Hi"
class C2(Generic[TypeT]):
def method(self, other: TypeT) -> str:
if issubclass(other, Base):
# reveal_type(other) == TypeT`1
return other.field # mypy error: "TypeT" has no attribute "field"
return "Hi"
Actual behavior as of 0.740 included in the comments above. Expected behavior would be to not raise an error on the penultimate line.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normal