From 2df6f365b52a2a230c698af148a50ce7fb9d3108 Mon Sep 17 00:00:00 2001 From: William Santosa Date: Sat, 13 May 2023 19:09:04 -0700 Subject: [PATCH] Improved config_file.rst writing (#15234) Fixes #7961 --- docs/source/config_file.rst | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/source/config_file.rst b/docs/source/config_file.rst index 3b96e6bd7a5a..92b0d51e3b12 100644 --- a/docs/source/config_file.rst +++ b/docs/source/config_file.rst @@ -3,17 +3,22 @@ The mypy configuration file =========================== -Mypy supports reading configuration settings from a file. By default -it uses the file ``mypy.ini`` with a fallback to ``.mypy.ini``, then ``pyproject.toml``, -then ``setup.cfg`` in the current directory, then ``$XDG_CONFIG_HOME/mypy/config``, then -``~/.config/mypy/config``, and finally ``.mypy.ini`` in the user home directory -if none of them are found; the :option:`--config-file ` command-line flag can be used -to read a different file instead (see :ref:`config-file-flag`). +Mypy supports reading configuration settings from a file with the following precedence order: + + 1. ``./mypy.ini`` + 2. ``./.mypy.ini`` + 3. ``./pyproject.toml`` + 4. ``./setup.cfg`` + 5. ``$XDG_CONFIG_HOME/mypy/config`` + 6. ``~/.config/mypy/config`` + 7. ``~/.mypy.ini`` It is important to understand that there is no merging of configuration -files, as it would lead to ambiguity. The :option:`--config-file ` flag -has the highest precedence and must be correct; otherwise mypy will report -an error and exit. Without command line option, mypy will look for configuration files in the above mentioned order. +files, as it would lead to ambiguity. The :option:`--config-file ` +command-line flag has the highest precedence and +must be correct; otherwise mypy will report an error and exit. Without the +command line option, mypy will look for configuration files in the +precedence order above. Most flags correspond closely to :ref:`command-line flags ` but there are some differences in flag names and some @@ -103,8 +108,8 @@ their name or by (when applicable) swapping their prefix from ``disallow`` to ``allow`` (and vice versa). -Examples -******** +Example ``mypy.ini`` +******************** Here is an example of a ``mypy.ini`` file. To use this config file, place it at the root of your repo and run mypy.