-
-
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
documentation on how to configure MYPYPATH is needed #1339
Comments
In general it's not a great practice to try and let mypy follow all imports to 3rd party packages; it usually leads to complaints about those 3rd party packages and/or poor checking because the typical 3rd party package doesn't have annotations. A better approach is to develop stubs for the 3rd party modules that you care about, and then (with approval of the 3rd party module's developers) contribute them to https://github.com/python/typeshed. |
While you don't yet have stubs for some third-party modules you're using, a very helpful flag to use is
This has the effect that when mypy sees an import of a module and it's neither
A typical command line would then look like Probably the best workflow for you will be to use a command line like that, and then also as you find yourself wanting types on things imported from third-party libraries write stubs for them. We should still also document MYPYPATH clearly! Particularly as some libraries may start adopting type annotations, or as you might add annotations to libraries of your own which your other code depends on. To help us most effectively document it, can you tell us where you looked when trying to figure it out? |
oh, excellent, Perhaps it should be set by default? If not set by default I would suggest that |
Documenting everything around -s and MYPYPATH clearly is important. (See also #1367.) The docs should emphasize that when you're confronted with a stdlib or 3rd party module or package for which stubs aren't in typeshed yet, you most likely don't want to extend MYPYPATH to analyze the module/package itself. (For stdlib modules, mypy has a list of known stdlib modules used to change the error message when a stdlib module has no stub; but for 3rd party modules it's pretty hopeless to try and maintain such a list.) |
as suggested in python#1339 alter module_not_found suggestion to "(Perhaps setting MYPYPATH or using the "--silent" flag would help)"
as suggested in #1339 alter module_not_found suggestion to "(Perhaps setting MYPYPATH or using the "--silent-imports" flag would help)"
In trying to provide more information on #1319 I ran into lots of problems with trying to set
MYPYPATH
. There doesn't seem to be any documentation on how it should be set.For example my library has the following
__init__.py
file:This seems to cause mypy a lot of problems.
My project uses
virtualenv
andpip
to install packages,sys.path
looks as follows:What value should I set
MYPYPATH
to to allow checking a script includingdistutils.version
? All the things I tried failed.I think partially related to #1293.
The text was updated successfully, but these errors were encountered: