This generates a false positive on the last line:
fromtypingimportTypeVar, Generic, Union, AnyT=TypeVar('T')
Tcov=TypeVar('Tcov', covariant=True)
S=TypeVar('S')
classA(Generic[Tcov]): passclassB(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.
This generates a false positive on the last line:
The error message is confusing, since
B[Any]andB[int]are compatible.We perhaps shouldn't use the type context from
afor type inference in this case.This issue affects built-in
listandSequencetype context with the latest typeshed master.