Open
Description
Mypy just says that class is not compatible with the bound when type checking this example:
from typing import Protocol, Generic, TypeVar, NamedTuple, List, Any
class Example(Protocol):
sentence: List[str]
T = TypeVar('T', bound=Example)
class Dataset(Generic[T]):
...
class ConcreteExample(NamedTuple):
sentence: List[str]
others: Any
class ConcreteDataset(Dataset[ConcreteExample]):
...
Here's the error message:
t.py:15: error: Type argument "Tuple[builtins.list[builtins.str], Any, fallback=t.ConcreteExample]" of "Dataset" must be a subtype of "t.Example"
It would be better to also say that sentence
in ConcreteExample
is read-only, and maybe suggest making it a read-only property in the protocol.
Originally reported in #7212.