class A(object):
def __init__(self):
self.a = 0
def __iadd__(self, a):
# type: (int) -> A
self.a += 1
return self
a = A()
a += 1
b = {0: a}
b[0] += 1
c = [a]
c[0] += 1
print(a.a)
Yields the following errors:
rt1.py:15: error: Incompatible types in assignment (expression has type "int", target has type "A")
rt1.py:18: error: No overload variant of "__setitem__" of "list" matches argument types [builtins.int, builtins.int]