-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow installing stub packages in mypy's Python as a fallback #5651
Comments
Hm, this makes me feel a bit uneasy. There are cases where this might not be possible (e.g. a Python 2 only dependency). I would much rather have mypy look in the other Python executable for the plugin than have mypy break the model of "We look at the Python executable pointed at via python_executable or python_version for typed packages". |
That was my POV too, but Ivan's argument was that then you'd to execute two pip commands (using two different interpreters!) to install the typing support for such packages. That has much more of a chance of breaking, since it's likely that some kind of coordination between versions of the plugin and the stubs is needed. |
@gvanrossum but if we search for plugins based on |
Also there seems to be some misunderstanding about what I am proposing: |
@ethanhs |
I suppose I am okay with this. It makes me feel uneasy, but I can't disagree that it has good ergonomic benefits. |
Currently PEP 561 specifies that stub packages (like
sqlalchemy-stubs
) should be installed in the site packages of the Python version of the program that is being checked:However, there is an important use case for stub packages that is incompatible with such path resolution scheme: single installation for stubs accompanied by a plugin. For example, all large frameworks like Django, NumPy, SQLAlchemy, etc. require both stubs and mypy plugins to properly type-check code using them. Ideally, a user should be able to just
pip install
them (stubs and mypy plugin) in one place, which is the place where mypy is installed.What I propose is to add a sentence like (approximately): "If the package is not found in that version, it is searched in the version of Python where the type checker is running."
@ethanhs What do you think?
NOTE: Currently this accidentally works in mypy. I propose to make this an officially supported feature, and add proper support to mypy.
The text was updated successfully, but these errors were encountered: