Skip to content

-s disables cross-checks between listed files #2012

Closed
@toejough

Description

@toejough

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:

  • uses local, fully typed files
  • uses a third-party, fully typed module (call it is_typed)
  • uses a third-party, untyped module (call it not_typed)

If I run mypy a.py b.py initially, I get an error about how it can't find is_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 to not_typed, plus a few about failures where a.py calls something in b.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 get AssertionError: 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 run MYPYPATH="/path/to/virtualenv/site-packages" mypy a.py b.py again aaaaand... All the errors for not_typed.

So then I got desperate and tried thing = importlib.import_module('not_typed.sub').thing, and that resulted in Invalid Type "b.thing" everywhere I used the thing type in b.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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions