Check types in assignment statement [assignment]
Mypy checks that the assigned expression is compatible with theassignment target (or targets).
Example:
- class Resource:
- def __init__(self, name: str) -> None:
- self.name = name
- r = Resource('A')
- r.name = 'B' # OK
- # Error: Incompatible types in assignment (expression has type "int",
- # variable has type "str") [assignment]
- r.name = 5