-- Test cases for generating fine-grained dependencies involving generics. -- -- The dependencies are used for fined-grained incremental checking. -- -- See the comment at the top of deps.test for more documentation. [case testGenericFunction] from typing import TypeVar T = TypeVar('T') class A: pass def f(x: T) -> T: y: T z: A return x [out] -> m.A, m.f -> , m.f [case testGenericClass] from typing import TypeVar, Generic T = TypeVar('T') class A(Generic[T]): pass class B: pass def f() -> None: a: A[B] [out] -> m.A, m.f -> m.B, m.f -> m.A [case testGenericClassWithMembers] from typing import TypeVar, Generic T = TypeVar('T') class A(Generic[T]): def g(self, a: T) -> None: self.x = a def f(self) -> T: return self.x [out] -> m.A.f, m.A.g -> m.A -> , , , m.A, m.A.f, m.A.g [case testGenericClassInit] from typing import TypeVar, Generic T = TypeVar('T') class A(Generic[T]): def __init__(self, a: T) -> None: self.x = a class B: pass def f() -> None: a = A(B()) [out] -> m.f -> m.f -> m.A.__init__ -> m.A, m.f -> m.f -> m.f -> m.B, m.f -> , , m.A, m.A.__init__ [case testGenericMethod] from typing import TypeVar T = TypeVar('T') class A: def f(self, x: T) -> T: return x [out] -> m.A -> , m.A.f [case testGenericBaseClass] from typing import TypeVar, Generic T = TypeVar('T') class A(Generic[T]): pass class B(A[C]): pass class C: pass [out] -> , m -> -> -> m, m.A, m.B -> m.B -> m, m.B, m.C -> m.A [case testGenericBaseClass2] from typing import TypeVar, Generic T = TypeVar('T') class A(Generic[T]): pass class B(A[T]): pass [out] -> , m -> -> -> m, m.A, m.B -> m.B -> m, m.A, m.B [case testTypeVarBound] from typing import TypeVar, Tuple class A: pass class B: pass T = TypeVar('T', bound=Tuple[A, B]) def f(x: T) -> T: return x [builtins fixtures/tuple.pyi] [out] -> , , m, m.A, m.f -> , , m, m.B, m.f -> , m.f [case testTypeVarBoundOperations] from typing import TypeVar, Tuple class A: def f(self) -> None: pass def __add__(self, other: int) -> int: pass T = TypeVar('T', bound=A) def f(x: T) -> None: x.f() x + 1 [out] -> m.f -> m.f -> , , m, m.A, m.f -> , m.f [case testTypeVarValues] from typing import TypeVar class A: pass class B: pass class C: pass class D: pass T = TypeVar('T', A, B) S = TypeVar('S', C, D) def f(x: T, y: S) -> S: pass [out] -> , , m, m.A, m.f -> , , m, m.B, m.f -> , , m, m.C, m.f -> , , m, m.D, m.f -> , m.f -> , m.f [case testTypeVarValuesMethod] from typing import TypeVar, Generic class C: pass class D: pass S = TypeVar('S', C, D) class G(Generic[S]): def f(self) -> S: pass [out] -> , , m, m.C, m.G.f -> , , m, m.D, m.G.f -> m.G -> , m.G, m.G.f [case testTypeVarValuesMethodAttr] from typing import TypeVar, Generic class A: x: int class B: x: int T = TypeVar('T', A, B) class G(Generic[T]): def f(self, x: T) -> None: x.x [out] -> m.G.f -> , , m, m.A, m.G.f -> m.G.f -> , , m, m.B, m.G.f -> m.G -> , m.G, m.G.f