3
它看起來像Mypy沒有做任何事情來推斷簽名。那是對的嗎?例如:Mypy:沒有簽名推理?
# types.py
def same_int(x: int) -> int:
return x
def f(x):
y = same_int(x)
# This would be "Unsupported operand types for + ("int" and "str")"
# y + "hi"
return y
f("hi")
f(1) + "hi"
沒有抱怨當我這樣做:
mypy --check-untyped-defs types.py
Mypy將使推理有關的f
體內表達式(如果--check-untyped-defs
已開啓)。我想知道使用它來製作和應用關於簽名的推論是否合理。 (如果沒有,爲什麼不),