The mypy configuration file
Mypy supports reading configuration settings from a file. By defaultit uses the file mypy.ini
with fallback to setup.cfg
in the currentdirectory, then $XDG_CONFIG_HOME/mypy/config
, then~/.config/mypy/config
, and finally .mypy.ini
in the user home directoryif none of them are found; the —config-file
command-line flag can be usedto read a different file instead (see Config file).
It is important to understand that there is no merging of configurationfiles, as it would lead to ambiguity. The —config-file
flaghas the highest precedence and must be correct; otherwise mypy will reportan error and exit. Without command line option, mypy will look for defaults,but will use only one of them. The first one to read is mypy.ini
,and then setup.cfg
.
Most flags correspond closely to command-line flags but there are some differences in flag names and someflags may take a different value based on the module being processed.
Some flags support user home directory and environment variable expansion.To refer to the user home directory, use ~
at the beginning of the path.To expand environment variables use $VARNAME
or ${VARNAME}
.