Changing types when reading a number
People will often reuse the same variable to first hold the string and then the number. This is ok with Python, but might be confusingt to the reader.
num = input("type in an integer: ") print(num) print(type(num).__name__) # str num = int(num) print(num) print(type(num).__name__) # int
mypy input.py will print the following:
input.py:6: error: Incompatible types in assignment (expression has type "int", variable has type "str") Found 1 error in 1 file (checked 1 source file)