As an example, executing this code with Python versions older than 3.9 will raise an exception:
from concurrent.futures import Future
f: Future[int]
TypeError: 'type' object is not subscriptable
But mypy will not complain (I'm using mypy 0.910):
Success: no issues found in 1 source file
Explicitly specifiying the Python version that mypy will use (e.g. --python-version=3.8) does not change this.
Numerous times I have fallen into the trap of writing code that uses features from newer Python versions, assuming that mypy will tell me if I made any errors, to then discover these errors only later at runtime.
How can I tell mypy to not assume features from certain Python versions (which I don't even have installed) to exist?