Check types in assignment statement [assignment]

Mypy checks that the assigned expression is compatible with theassignment target (or targets).

Example:

  1. class Resource:
  2. def __init__(self, name: str) -> None:
  3. self.name = name
  4.  
  5. r = Resource('A')
  6.  
  7. r.name = 'B' # OK
  8.  
  9. # Error: Incompatible types in assignment (expression has type "int",
  10. # variable has type "str") [assignment]
  11. r.name = 5