Lets say I have a simple function inside the file home/func.py, and I make one call to it.
def f(x):
return x
print(f("example"))
Now lets say I want to type check this function using a stub, home/stubs/func.pyi which looks like:
def f(x: int): ...
Now I want to check my code with mypy to see if I've made any typing mistakes. Running mypy on home/func.py I would expect an warning/error like: Got string where int was expected - however I can't get this functionality to work.
What I've read online and in the docs suggests I should create a home/mypy.ini config file with the following contents:
[mypy]
mypy_path = $MYPY_CONFIG_FILE_DIR/stubs
and then I should run mypy while pointing to this config, so something like: python -m mypy --config mypy.ini func.py. This has not worked.
I know I could use typing annotations in the function definition but in this case the use of stubs is non-optional. Any help is really really appreciated.