basedpyright
basedpyright copied to clipboard
explicit covariance on old `TypeVar`s is not checked at all unless the generic is the only part of the type annotation
Code sample in basedpyright playground
from typing import Generic, TypeVar
T = TypeVar("T", covariant=True)
class Foo(Generic[T]):
def b(self, value: T | int) -> None: ... # no error
not just unions:
Code sample in basedpyright playground
from typing import Generic, TypeVar
from collections.abc import Sequence
T = TypeVar("T", covariant=True)
class Foo(Generic[T]):
def asdf(self, value: Sequence[T]) -> None: # no error
...