我有以下代码:
a_round = round (3.5) # First use of a_round
a_round = 4.5 # Incompatible types, since a_round is regarded as an int
原来round()的返回值被认为是一个int。之所以如此,我得出结论是因为在第二个语句中,mypy 抱怨:
Incompatible types in assignment (expression has type "float",variable has type "int")
我使用的是 Python 3.5,所以它应该是一个浮点数。我错过了什么。我应该以某种方式向 mypy 暗示 Python 版本吗?具体如何?