You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We planned to have .pyi stubs of each python file separately in a folder named stubs and give the path to stubs folder in mypy.ini file.
I learnt from this stack overflow answer that the stub file works only when importing a module. So I wrote a basic test file in tests folder which basically imports and calls the methods present in mypy/main.py.
When I run mypy tests/test-main.py I get
mypy/main.py:1: error: Function is missing a type annotation mypy/main.py:5: error: Function is missing a type annotation mypy/main.py:9: error: Function is missing a type annotation
Though I gave path to stubs folder in mypy.ini file I believe mypy is still not considering stubs/mypy/main.pyi file. If stubs/mypy/main.pyi is considered it should throw me some errors as some of the returns types mentioned in main.pyi are incorrect.
Can someone please help me in knowing where am I exactly going wrong? In other words how do I place .pyi files in a separate folder and run mypy?
Just to point out, if both main.py and main.pyi are in same folder things are working.
Thanks
The text was updated successfully, but these errors were encountered:
waseem18
changed the title
How to separate .pyi files from .py files?
Issue with havivng .pyi files in a separate folder [Question - Need help]
Apr 19, 2018
Hi, thank you for a complete repro. You've actually made two mistakes.
The first is the mypy path should point to the directory above the package you want it to find (a package is a folder with a init.py[i]). So you should just be able to say ./stubs.
The second is that your stubs folder is not a package! It doesn't have a __init__.pyi in the mypy folder. Changing these fixes the issues and gives expected output. Let me know if you have further questions.
This is more of a question than an issue.
I'm starting on using
mypy
and here's the minimal version of the project I'm type hinting - https://github.com/waseem18/mypyWe planned to have
.pyi
stubs of each python file separately in a folder namedstubs
and give the path to stubs folder inmypy.ini
file.I learnt from this stack overflow answer that the stub file works only when importing a module. So I wrote a basic test file in
tests
folder which basically imports and calls the methods present inmypy/main.py
.When I run
mypy tests/test-main.py
I getmypy/main.py:1: error: Function is missing a type annotation
mypy/main.py:5: error: Function is missing a type annotation
mypy/main.py:9: error: Function is missing a type annotation
Though I gave path to stubs folder in
mypy.ini
file I believemypy
is still not consideringstubs/mypy/main.pyi
file. Ifstubs/mypy/main.pyi
is considered it should throw me some errors as some of the returns types mentioned inmain.pyi
are incorrect.Can someone please help me in knowing where am I exactly going wrong? In other words how do I place
.pyi
files in a separate folder and runmypy
?Just to point out, if both
main.py
andmain.pyi
are in same folder things are working.Thanks
The text was updated successfully, but these errors were encountered: