You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a package A which imports multiple my package B, C and so on. All of the packages have typing annotations, but they are not public. I am trying to integrate mypy into my CI, where I install all dependencies for A and try to type check current code. The issue is that my other packages cannot be imported. On the other hand, if I use MYPYPATH to point it to site-packages directory where they were installed, mypy tries to type check many other packages which then fail (despite some of them having stubs, and other imports have # type: ignore next to them).
Now, reading documentation it seems that the expected thing would be that I generate stub files for other packages? But where do I put them? If I put them next to package files, then I have to point MYPYPATH to site-packages and we are again to square one. If I put them elsewhere, how do I easily get them through installation of requirements? Also, if my code is nicely typed, why should I be generating stub files at all and worry if they are in sync with code?
It seems that the other option would be to put my dependencies in a separate directory, but then I have to duplicate my dependencies installation and copying them into a separate directory, double work, especially because the first one is done automatically.
So I would suggest that:
if import A has next to it a comment # type: ignore, that package is not even tried to be imported and analyzed
that I could list on the command line, use things you find in MYPY, but just for package B, C, and so on (fragile, I have to keep this list manually)
that if a standard library has stubs, it does not try to load it and analyze it
So maybe just the first and last suggestion would already work for me. If I see that some import is blowing up, I could just add # type: ignore to it and it wouldn't. And all standard libraries would keep working. And then only those other relevant imports of B and C would matter. In that case, it would be great if mypy could automatically load from sys.path. So that I would not have to run it with:
A problem with your proposed semantics for # type: ignore is that in general the presence of # type: ignore should not change the behavior of the checker -- it should only suppress errors generated on that line.
What about then # type: recursive ignore? :-) So to suppress any errors in imported modules as well. And then we can see the fact that checker does not go into import only as an optimization.
I have a package
A
which imports multiple my packageB
,C
and so on. All of the packages have typing annotations, but they are not public. I am trying to integrate mypy into my CI, where I install all dependencies forA
and try to type check current code. The issue is that my other packages cannot be imported. On the other hand, if I useMYPYPATH
to point it to site-packages directory where they were installed, mypy tries to type check many other packages which then fail (despite some of them having stubs, and other imports have# type: ignore
next to them).Now, reading documentation it seems that the expected thing would be that I generate stub files for other packages? But where do I put them? If I put them next to package files, then I have to point
MYPYPATH
to site-packages and we are again to square one. If I put them elsewhere, how do I easily get them through installation of requirements? Also, if my code is nicely typed, why should I be generating stub files at all and worry if they are in sync with code?It seems that the other option would be to put my dependencies in a separate directory, but then I have to duplicate my dependencies installation and copying them into a separate directory, double work, especially because the first one is done automatically.
So I would suggest that:
import A
has next to it a comment# type: ignore
, that package is not even tried to be imported and analyzedB
,C
, and so on (fragile, I have to keep this list manually)So maybe just the first and last suggestion would already work for me. If I see that some import is blowing up, I could just add
# type: ignore
to it and it wouldn't. And all standard libraries would keep working. And then only those other relevant imports ofB
andC
would matter. In that case, it would be great if mypy could automatically load fromsys.path
. So that I would not have to run it with:The text was updated successfully, but these errors were encountered: