-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
-s disables cross-checks between listed files #2012
Comments
Thanks for this writeup! I think the shortest direct answer is that we don't currently have great support for third-party libraries that have themselves adopted PEP 484 types -- that is, for libraries that aren't in your own codebase's source tree and live instead in something like a Clearly this is a situation that will become more and more important as more library authors adopt static type annotations -- we should definitely find a better solution than we have. The workflow that currently definitely does work great is: all the files you want to actually type-check are in your source tree, and you pass them (or the directories containing them) to a That workflow is pretty much what you describe with Issue #1190 is the main one we have discussing this problem. Does that look like it covers what you're describing? |
The one thing I'd add is that setting MYPYPATH to point to site-packages is
basically always wrong, and is likely to cause crashes. This is not great,
but it's a good thing to be aware of in the current stage of mypy's
development.
|
@gvanrossum - ah, ok. thanks for the tip! @gnprice - thanks for the response! So, maybe I should stop filing bugs at the end of my work day. #1190 is definitely part of the problem I was having, so thanks for pointing that one out. The bigger part of my problem, though, was that it seemed like My best guess is that the type error I was looking for was actually dependent on Thanks again for the responses and thought - and apologies for the noise. If I can reproduce AND get it down to a minimal example, I'll open a new issue, but for now I'd consider this one closed. |
One more tip: -s is a measure of last resort. Also try -almost-silent
instead.
…--Guido (mobile)
|
I'm having a compound issue, and I'm not sure if each part of this deserves an issue. The thing that bothers me the most is the missing cross-checks, but to get there, it might be helpful to explain some context...
I've got a project that:
is_typed
)not_typed
)If I run
mypy a.py b.py
initially, I get an error about how it can't findis_typed
, and maybe I should either use MYPYPATH or--silent-imports
.When I run
MYPYPATH="/path/to/virtualenv/site-packages" mypy a.py b.py
, I get a ton of failures related tonot_typed
, plus a few about failures wherea.py
calls something inb.py
with the wrong type.These last set are the errors I'm calling cross-check failures. I want to see those. I don't want to see the earlier set - I know that
not_typed
is not typed, and I'm not going to make stubs for that project at the moment.Back to the example. Setting the full site-packages dir grabbed more than I wanted. If I run
MYPYPATH="/path/to/virtualenv/site-packages/is_typed" mypy a.py b.py
, I getAssertionError: Neither id, path nor source given
, with a stack trace. If I add--pdb
to the call to try to debug, I do not get dropped into the debugger.Ok. Well, let's try the
--silent-imports
then.mypy -s a.py b.py
results in a clean run. The cross-check failures do not show up, even though they're still there. :-(Ok. Well, let's try
from not_typed.sub import thing # type: ignore
. Then runMYPYPATH="/path/to/virtualenv/site-packages" mypy a.py b.py
again aaaaand... All the errors fornot_typed
.So then I got desperate and tried
thing = importlib.import_module('not_typed.sub').thing
, and that resulted inInvalid Type "b.thing"
everywhere I used thething
type inb.py
.I think I ran into several real problems here, but I'm not convinced I'm not just doing it wrong somehow, because I don't see anyone else having the same issues here, and I don't think my use case is all that tricky.
Is there anything I can do differently?
The text was updated successfully, but these errors were encountered: