Currently if the second argument to isinstance has type Any, we don't narrow the type down. This doesn't work as expected with ignored imports. Example (assume that foo has a missing stub):
from typing import Union
from foo import A # type: ignore
def f(x: Union[A, str]) -> None:
if isinstance(x, A):
x.method_only_in_a() # Item "str" of "Union[Any, str]" has no attribute "method_only_in_a"
I'd expect the type of x to be 'narrowed' (actually widened) to Any, and mypy should probably not generate an error.