-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Installed stubs not always taking precedence in PEP 561 implementation #4876
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
Comments
AFAIK this was intentional -- the search finds the first directory that has
either a .py or a .pyi file, and then prefers .pyi over .py -- but it
doesn't continue to search for .pyi files further down on the path if the
first hit has only a .py file.
Perhaps with PEP 561 we want to change this?
|
I guess either approach could be okay, as long as it's clearly documented. Also, it would be good to have a way for mypy to print out the full search path, in case mypy isn't finding the expected stubs/annotations. |
The PEP is not specific here (see the section about this https://www.python.org/dev/peps/pep-0561/#type-checker-module-resolution-order), perhaps it should be. I think within the category of "installed packages" it shouldn't matter where they are installed. I have a simple patch which should fix this. (PR incoming) |
Due to the method of looking for installed packages, it was possible for the search to be unstable: an installed inline package would be chosen before an installed stub package. This corrects that by storing a seperate list for each, and putting the stub packages first. Fixes python#4876
Due to the method of looking for installed packages, it was possible for the search to be unstable: an installed inline package would be chosen before an installed stub package. This corrects that by storing a seperate list for each, and putting the stub packages first. Fixes #4876
WIP-1 Few more fixes for issues found by testing on internal codebases (python#4876) Few unrelated (but quite obvious) fixes here. Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
I installed a package with inline type annotations using
python setup.py install
and installed the corresponding stubs package usingpython setup.py install --user
. Mypy picked up the inline type annotations instead of the stubs, even though I'd expect that a stub package takes precedence. I suspect that this is caused by the package and the stubs being in different directories, and that the order in which we search through the directories may affect which types will be used by mypy.@ethanhs Can you take a look at this?
The text was updated successfully, but these errors were encountered: