Closed
Description
Currently, even with --follow-imports=skip
imports from stub files are still followed. This means that if stub imports an unanalyzed module, the previously unanalyzed module is actually typechecked.
Consider the following example:
# main.py
from stub import x
# stub.pyi
from unanalyzed import x
# unanalyzed.py
x: int = 42
x + '' # error is reported here but it shouldn't be because this file is unanalyzed
Currently, if you run mypy the following happens:
$ mypy main.py --follow-imports=skip
unanalyzed.py:4: error: Unsupported operand types for + ("int" and "str")
I think we should treat imports from stub and non-stub files the same way. Following imports from stubs in silent mode was implemented #1372.
Discovered this bug when investigating an error in Dropbox internal codebases.