Skip to content

Commit 20f7f2d

Browse files
authored
Allow mypy.ini to be a dot file (#8515)
Fixes #8510.
1 parent bc590e4 commit 20f7f2d

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

docs/source/command_line.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ Config file
7373

7474
This flag makes mypy read configuration settings from the given file.
7575

76-
By default settings are read from ``mypy.ini`` or ``setup.cfg`` in the
77-
current directory, or ``.mypy.ini`` in the user's home directory.
78-
Settings override mypy's built-in defaults and command line flags
79-
can override settings.
76+
By default settings are read from ``mypy.ini``, ``.mypy.ini``, or ``setup.cfg``
77+
in the current directory. Settings override mypy's built-in defaults and
78+
command line flags can override settings.
8079

8180
Specifying :option:`--config-file= <--config-file>` (with no filename) will ignore *all*
8281
config files.

docs/source/config_file.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ The mypy configuration file
44
===========================
55

66
Mypy supports reading configuration settings from a file. By default
7-
it uses the file ``mypy.ini`` with fallback to ``setup.cfg`` in the current
8-
directory, then ``$XDG_CONFIG_HOME/mypy/config``, then
7+
it uses the file ``mypy.ini`` with a fallback to ``.mypy.ini``, then ``setup.cfg`` in
8+
the current directory, then ``$XDG_CONFIG_HOME/mypy/config``, then
99
``~/.config/mypy/config``, and finally ``.mypy.ini`` in the user home directory
1010
if none of them are found; the :option:`--config-file <mypy --config-file>` command-line flag can be used
1111
to read a different file instead (see :ref:`config-file-flag`).
@@ -15,7 +15,7 @@ files, as it would lead to ambiguity. The :option:`--config-file <mypy --config
1515
has the highest precedence and must be correct; otherwise mypy will report
1616
an error and exit. Without command line option, mypy will look for defaults,
1717
but will use only one of them. The first one to read is ``mypy.ini``,
18-
and then ``setup.cfg``.
18+
then ``.mypy.ini``, and finally ``setup.cfg``.
1919

2020
Most flags correspond closely to :ref:`command-line flags
2121
<command-line>` but there are some differences in flag names and some

mypy/defaults.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
PYTHON3_VERSION = (3, 6) # type: Final
77
PYTHON3_VERSION_MIN = (3, 4) # type: Final
88
CACHE_DIR = '.mypy_cache' # type: Final
9-
CONFIG_FILE = 'mypy.ini' # type: Final
9+
CONFIG_FILE = ['mypy.ini', '.mypy.ini'] # type: Final
1010
SHARED_CONFIG_FILES = ['setup.cfg', ] # type: Final
1111
USER_CONFIG_FILES = ['~/.config/mypy/config', '~/.mypy.ini', ] # type: Final
1212
if os.environ.get('XDG_CONFIG_HOME'):
1313
USER_CONFIG_FILES.insert(0, os.path.join(os.environ['XDG_CONFIG_HOME'], 'mypy/config'))
1414

15-
CONFIG_FILES = [CONFIG_FILE, ] + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
15+
CONFIG_FILES = CONFIG_FILE + SHARED_CONFIG_FILES + USER_CONFIG_FILES # type: Final
1616

1717
# This must include all reporters defined in mypy.report. This is defined here
1818
# to make reporter names available without importing mypy.report -- this speeds

0 commit comments

Comments
 (0)