-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
--package flag does not work with installed packages #7087
Comments
Hm, I would say this should work (unless I am missing something). |
Unfortunately the Agreed we should fix this. If you can come up with a PR that would be awesome! |
Unfortunately, to my knowledge, it is not possible to run the type checking on the built and installed package, see github issue below for details: python/mypy#7087
I discovered this while working on pypa/twine#618, and thinking that it would be nice to run mypy against the installed package. See the comments for more details (including some proposed tox configurations). Poking around a bit, it seems like this is the entry point to the import-following code for Lines 900 to 917 in 22e504b
|
This appears to be working now. Big thanks to whoever fixed it. |
It's not working for me! I'm on mypy-0.812. |
@fitzymj Curious. In what sense does it not work for you? I set up a somewhat controlled job to sanity check myself and my conclusion is still that it works. Notice how the older version fails because it does not find the package to type check whereas the new version fails because the type check fails. |
Could be because I'm on Python 3.7, could be because I'm on Windows? This shows it pretty clearly:
|
Is Look in a path like |
That did it, thanks! I went back to 0.782 and it did not fix it, so I feel a little better. Ditto on the thanks to whomever fixed it in 0.812! |
You are welcome. |
In short, I expect the below to not fail
mypy -p mypy # Can't find package 'mypy'
The way I read the documentation and related issues such as 6394, the
--package
option should find named package among installed packages and check it recursively. For instance, I expect mypy to be be able to type check itself. As demonstrated this Is not the case.The
--module
option on the other hand works fine:mypy -m mypy # no output
Explicitly setting the
MYPYPATH
resolves the issue:MYPYPATH=venv/lib/python3.7/site-packages mypy -p mypy # lots of output
However, this solution does not work inside tox where mypy will complain
.tox/py37-mypypath-m/lib/python3.7/site-packages is in the MYPYPATH. Please remove it.
It would be nice to be able to check typing on the package under development as an installed package because this would ensure that the package appears as typing enabled to third parties.
I uploaded a small package that also reproduces the problem here
OS: MacOS 10.14.5
Python: 3.7.2 (via pyenv)
Mypy: 0.720+dev.17b68c6b7eaa76853422544e32b1d6c5c3acc55a
The text was updated successfully, but these errors were encountered: