|
3 | 3 | The mypy configuration file |
4 | 4 | =========================== |
5 | 5 |
|
6 | | -Mypy supports reading configuration settings from a file. By default |
7 | | -it uses the file ``mypy.ini`` with a fallback to ``.mypy.ini``, then ``pyproject.toml``, |
8 | | -then ``setup.cfg`` in the current directory, then ``$XDG_CONFIG_HOME/mypy/config``, then |
9 | | -``~/.config/mypy/config``, and finally ``.mypy.ini`` in the user home directory |
10 | | -if none of them are found; the :option:`--config-file <mypy --config-file>` command-line flag can be used |
11 | | -to read a different file instead (see :ref:`config-file-flag`). |
| 6 | +Mypy supports reading configuration settings from a file with the following precedence order: |
| 7 | + |
| 8 | + 1. ``./mypy.ini`` |
| 9 | + 2. ``./.mypy.ini`` |
| 10 | + 3. ``./pyproject.toml`` |
| 11 | + 4. ``./setup.cfg`` |
| 12 | + 5. ``$XDG_CONFIG_HOME/mypy/config`` |
| 13 | + 6. ``~/.config/mypy/config`` |
| 14 | + 7. ``~/.mypy.ini`` |
12 | 15 |
|
13 | 16 | It is important to understand that there is no merging of configuration |
14 | | -files, as it would lead to ambiguity. The :option:`--config-file <mypy --config-file>` flag |
15 | | -has the highest precedence and must be correct; otherwise mypy will report |
16 | | -an error and exit. Without command line option, mypy will look for configuration files in the above mentioned order. |
| 17 | +files, as it would lead to ambiguity. The :option:`--config-file <mypy --config-file>` |
| 18 | +command-line flag has the highest precedence and |
| 19 | +must be correct; otherwise mypy will report an error and exit. Without the |
| 20 | +command line option, mypy will look for configuration files in the |
| 21 | +precedence order above. |
17 | 22 |
|
18 | 23 | Most flags correspond closely to :ref:`command-line flags |
19 | 24 | <command-line>` but there are some differences in flag names and some |
@@ -103,8 +108,8 @@ their name or by (when applicable) swapping their prefix from |
103 | 108 | ``disallow`` to ``allow`` (and vice versa). |
104 | 109 |
|
105 | 110 |
|
106 | | -Examples |
107 | | -******** |
| 111 | +Example ``mypy.ini`` |
| 112 | +******************** |
108 | 113 |
|
109 | 114 | Here is an example of a ``mypy.ini`` file. To use this config file, place it at the root |
110 | 115 | of your repo and run mypy. |
|
0 commit comments