Open
Description
from typing import MutableSet, Sequence, TypeVar
T = TypeVar('T', str, Sequence[str])
class CustomSet(MutableSet[T]):
def add(self, value: T) -> None:
pass
foo = CustomSet()
foo.add(('a', 'b'))
mypy 0.740 says: error: Argument 1 to "add" of "CustomSet" has incompatible type "Tuple[str, str]"; expected "str"
There's seemingly nothing I can do to get mypy to handle this pattern correctly. If I try explicitly specifying the type of foo
, it just complains that the assignment to it is incompatible.