-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
MYPYPATH not working with local -stubs package #5386
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
I wonder if mypy currently only looks for stub packages in the system Python's site-packages directory (and a few related ones, e.g. user-packages) but not along MYPYPATH. But it makes sense to also look there so it's easier to test stub packages. Ethan, what do you think? |
I think I was initially hesitant to do this as it would not be easy to do with the old search path implementation, and I thought editable installs would handle this use case. However, with my refactoring of search paths, this is very straightforward to implement. I still feel like using editable installs is the best way to test things (because that is the closest approximation to a real installation). To be clear: when you say MYPYPATH, do you mean MYPYPATH (as set by the user) joined with the PYTHONPATH (the files/directories the user points mypy at) or just the former? I think it might be a bit surprising if I check a test from the top level of a source tree to automatically pick up stubs in a subdirectory. In other words, if I checkeded |
Those are mostly questions for @Dentosal. I'm not sure why you're mentioning PYTHONPATH (which AFAIK is just the environment variable used by Python itself to find modules in addition to its default search path). But your example poses an interesting question. In site packages, of we have both |
Just adding the folder path
I'm not quite sure what the correct behavior should be. However, Mypy documentation says:
So I think adding the folder to |
Okay, I think I've convinced myself that stub packages in the MYPYPATH and pointed to by mypy should be picked up. I will work on an implementation soon. |
Hmm, I've sat and thought about this, and also implemented it. But I still feel like telling people to either install their stubs or name the package to be compatible with MYPYPATH is a better answer. It would also violate the assertion that packages on the MYPYPATH are valid Python identifiers, which bothers me. I am open for someone to convince me otherwise, but I'm not too keen to do this (though I am happy to add some documentation about the current state of things). |
OK, let's reject the feature request and instead add a bit of documentation. |
This is a bug report. However, if the current behavior is not a bug, then this is request to improve documentation.
Description
Mypy doesn't recognise my local library typing stub.
Reproduction:
Actual Python file
Directory tree
Mypy command
mypy.ini
:Actual behavior
Expected behavior
Import succeeds, Mypy uses the stub
Versions
Python 3.6.5
mypy 0.620
The text was updated successfully, but these errors were encountered: