Platform configuration
By default, mypy will assume that you intend to run your code using the sameoperating system and Python version you are using to run mypy itself. Thefollowing flags let you modify this behavior.
For more information on how to use these flags, see Python version and system platform checks.
—python-version
X.Y
- This flag will make mypy type check your code as if it wererun under Python version X.Y. Without this option, mypy will default to usingwhatever version of Python is running mypy. Note that the
-2
and—py2
flags are aliases for—python-version 2.7
.
This flag will attempt to find a Python executable of the correspondingversion to search for PEP 561 compliant packages. If you’d like todisable this, use the —no-site-packages
flag (seeImport discovery for more details).
-2
,
—py2
- Equivalent to running
—python-version 2.7
.
—platform
PLATFORM
- This flag will make mypy type check your code as if it wererun under the given operating system. Without this option, mypy willdefault to using whatever operating system you are currently using.
The PLATFORM
parameter may be any string supported bysys.platform
.