I am trying the typing hint introduced by Python 3.5 and got a problem by using local stubs as the typing hint with mypy.
The experiment I do is to create kk.py containing
def type_check(a):
pass
Also, I put kk.pyi containing
def type_check(a: int):...
in the same directory. In this way, I tried to trigger the error of "incompatible types in assignment" by passing a string to type_check
in kk.py
. However, when I ran mypy kk.py
, I get no error.
Thus I tried another way that mypy doc suggests, which is to set environment variable MYPYPATH to ~/some/path/stub
and put kk.pyi
in the directory. I didn't get any error again.
Anyone can help me on this?
Here is the mypy wiki on how to use a local stub.