Код: Выделить всё
class C : pass
def f1( c : C ) : pass
f1( 100)
def f2( c : C = None ) : pass
f2( 100)
Код: Выделить всё
$ mypy 002_1.py
002_1.py:11: error: Argument 1 to "f1" has incompatible type "int"; expected "C"
002_1.py:15: error: Argument 1 to "f2" has incompatible type "int"; expected "Optional[C]"
Found 2 errors in 1 file (checked 1 source file)
Но когда у меня есть такой код:
Код: Выделить всё
class C : pass
def f1( c : C ) : pass
def f2( c : C = None ) : pass
def test001() :
f1( 100)
f2( 100)
test001()
Я использую mypy 0.812 и Python 3.9.2.
Что делать, чтобы увидеть ошибку ввода?
Подробнее здесь: https://stackoverflow.com/questions/790 ... a-function