Skip to content

Commit 2df6f36

Browse files
Improved config_file.rst writing (#15234)
Fixes #7961
1 parent f176f6a commit 2df6f36

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

docs/source/config_file.rst

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
The mypy configuration file
44
===========================
55

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``
1215

1316
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.
1722

1823
Most flags correspond closely to :ref:`command-line flags
1924
<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
103108
``disallow`` to ``allow`` (and vice versa).
104109

105110

106-
Examples
107-
********
111+
Example ``mypy.ini``
112+
********************
108113

109114
Here is an example of a ``mypy.ini`` file. To use this config file, place it at the root
110115
of your repo and run mypy.

0 commit comments

Comments
 (0)