Skip to content

Issue with havivng .pyi files in a separate folder [Question - Need help] #4933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
waseem18 opened this issue Apr 19, 2018 · 3 comments
Closed
Labels

Comments

@waseem18
Copy link

waseem18 commented Apr 19, 2018

This is more of a question than an issue.

I'm starting on using mypyand here's the minimal version of the project I'm type hinting - https://github.com/waseem18/mypy

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

@waseem18 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
@emmatyping
Copy link
Member

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.

@waseem18
Copy link
Author

Thanks for the response @ethanhs

I'll try that today evening and will let you know if I've any more questions.

@emmatyping
Copy link
Member

If you are still having problems feel free to leave a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants