We typically use the PyPi MyPy instead of conda, to have the most recent MyPy version:
pip install mypy
It’s often useful to have a per-project MyPy configuration file to avoid excessive command line options. Put a file .mypy.ini in each Python project containing:
[mypy] ignore_missing_imports = True strict_optional = False allow_redefinition = True show_error_context = False show_column_numbers = True
One can make a system-wide ~/.mypy.ini, that is overridden by the per-project .mypy.ini.
isolate problem packages
Sometimes an external package adds type hinting that is incompatible with the current MyPy release. This is relatively rare, but was the case with Xarray. To ignore a package’s type hinting, add the following to .mypy.ini, where we assume we want to ignore xarray type checking.
[mypy-xarray] follow_imports = skip