mypy icon indicating copy to clipboard operation
mypy copied to clipboard

no error when `TypeVar` with explicit variance is used in the wrong position when it's part of a union

Open DetachHead opened this issue 1 year ago • 0 comments

from typing import Generic, TypeVar

T = TypeVar("T", covariant=True)

class Foo(Generic[T]):
    def b(self, value: T | int) -> None: ... # no error

playground

DetachHead avatar Oct 10 '24 03:10 DetachHead