Description
Feature
Detect if $VIRTUAL_ENV
is defined when running mypy, potentially only if we report missing imports.
Pitch
Right now, if mypy is installed globally, and a user activates a virtual environment, they could be confused about missing import errors (e.g. #7237) where the packages are installed in the virtual environment but mypy can't see them. In such a scenario, we'd be able to detect that $VIRTUAL_ENV
is set, and we could report a warning if that path doesn't match the prefix of sys.executable
.
One question about this is should we report this in general or only if we report a missing import.
I think there probably are use cases where people don't care about running mypy globally, so my initial inclination would be to only report this and suggest --python-executable
if an import is missing.