Skip to content
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

Module in the virtualenv site-packages directory are not found by mypy #7788

Closed
nicoe opened this issue Oct 24, 2019 · 4 comments
Closed

Module in the virtualenv site-packages directory are not found by mypy #7788

nicoe opened this issue Oct 24, 2019 · 4 comments

Comments

@nicoe
Copy link

nicoe commented Oct 24, 2019

Hello,

With every mypy release I give it a try, this release is no different and the fact that environment variables are now taken into account in the config file will be very nice to find the python from the virtual environment.

So this is my config file:

nicoe@mirabelle:~% cat ~/.config/mypy/config
[mypy]
python_executable = $VIRTUAL_ENV/bin/python

When I execute this command:

mypy trytond/trytond/model/modelsql.py

(the complete file is available there: https://github.com/tryton/trytond/blob/develop/trytond/model/modelsql.py)

It won't find the sql package:

trytond/trytond/ir/lang.py:11: error: Cannot find module named 'sql'

Although the module is available through a simple import:

(tryton-trunk) nicoe@mirabelle:projets/tryton/tryton-env/tryton-env% python -c 'import sql; print(sql.__file__)'
/home/nicoe/.local/share/virtualenvs/tryton-trunk/lib/python3.7/site-packages/sql/__init__.py

And if I try to add this path to MYPYPATH it won't work either:

(tryton-trunk) nicoe@mirabelle:projets/tryton/tryton-env/tryton-env% MYPYPATH=/home/nicoe/.local/share/virtualenvs/tryton-trunk/lib/python3.7/site-packages/sql mypy trytond/trytond/model/modelsql.py
/home/nicoe/.local/share/virtualenvs/tryton-trunk/lib/python3.7/site-packages is in the MYPYPATH. Please remove it.
See https://mypy.readthedocs.io/en/latest/running_mypy.html#how-mypy-handles-imports for more info

Am I missing anything?

@emmatyping
Copy link
Collaborator

Have you tried manually passing --python-executable= via command line? Also please pass -vv, which should give more info.

@emmatyping
Copy link
Collaborator

Oh, if you are using python-sql, the package doesn't have a py.typed, nor does it have type annotations.

@nicoe
Copy link
Author

nicoe commented Oct 25, 2019

OK thanks.

Since I saw some "No library stub file for module 'lxml'", I though mypy was not able to find the python-sql library while it was able to find the lxml one.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 28, 2019

This seems like the same issue as #4542, which is already high priority.

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

No branches or pull requests

3 participants