In a directory with the following structure:
src/
my_module/
foo.py
bar.py
I run MyPy using mypy src/mymodule.
If there is the following in a single file (e.g. foo.py):
# foo.py
def hey(whatever: str) -> int:
return 234
hey(22)
Then MyPy will complain, as it should.
$ mypy src/my_module
src/my_module/foo.py:4: error: Argument 1 to "hey" has incompatible type "int"; expected "str"
However, if one file calls a function from another file:
# foo.py
def hey(whatever: str) -> int:
return 234
# bar.py
from foo import hey
hey(22)
Then MyPy finds no error:
$ mypy src/mymodule
Success: no issues found in 2 source files
How to make sure that MyPy checks type consistency between different files?