-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongfalse-positivemypy gave an error on correct codemypy gave an error on correct codepriority-1-normaltopic-type-variables
Description
This generates a false positive on the last line:
from typing import TypeVar, Generic, Union, Any
T = TypeVar('T')
Tcov = TypeVar('Tcov', covariant=True)
S = TypeVar('S')
class A(Generic[Tcov]): pass
class B(A[T]):
def __add__(self, x: B[S]) -> B[Union[T, S]]: ...
a: A[object]
b1: B[Any]
b2: B[int]
a = b1 + b2 # Unsupported operand types for + ("B[Any]" and "B[int]")
The error message is confusing, since B[Any]
and B[int]
are compatible.
We perhaps shouldn't use the type context from a
for type inference in this case.
This issue affects built-in list
and Sequence
type context with the latest typeshed master.
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-normaltopic-type-variables