Check type variable values [type-var]

Mypy checks that value of a type variable is compatible with a valuerestriction or the upper bound type.

Example:

  1. from typing import TypeVar
  2.  
  3. T1 = TypeVar('T1', int, float)
  4.  
  5. def add(x: T1, y: T1) -> T1:
  6. return x + y
  7.  
  8. add(4, 5.5) # OK
  9.  
  10. # Error: Value of type variable "T1" of "add" cannot be "str" [type-var]
  11. add('x', 'y')