Skip to content
/ mypy Public
forked from python/mypy

Commit b8d3b6c

Browse files
committed
Revert to treating exclude in .ini as single string
Fixes python#11830. Depends on python#11828.
1 parent bbd5431 commit b8d3b6c

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

docs/source/config_file.rst

+7-6
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,19 @@ section of the command line docs.
197197

198198
.. confval:: exclude
199199

200-
:type: newline separated list of regular expressions
200+
:type: regular expressions
201201

202-
A newline list of regular expression that matches file names, directory names and paths
202+
A regular expression that matches file names, directory names and paths
203203
which mypy should ignore while recursively discovering files to check.
204204
Use forward slashes on all platforms.
205205

206206
.. code-block:: ini
207207
208208
[mypy]
209-
exclude =
209+
exclude = (?x)(
210210
^file1\.py$
211-
^file2\.py$
211+
|^file2\.py$
212+
)
212213
213214
For more details, see :option:`--exclude <mypy --exclude>`.
214215

@@ -997,8 +998,8 @@ of your repo (or append it to the end of an existing ``pyproject.toml`` file) an
997998
warn_return_any = true
998999
warn_unused_configs = true
9991000
exclude = [
1000-
'^file1\.py$', # TOML single-quoted string (no escaping necessary)
1001-
"^file2\\.py$", # TOML double-quoted string (backslash needs escaping)
1001+
'^file1\.py$', # TOML literal string (single quotes, no escaping necessary)
1002+
"^file2\\.py$", # TOML basic string (double quotes, backslash and other characters need escaping)
10021003
]
10031004
10041005
# mypy per-module options:

mypy/config_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def check_follow_imports(choice: str) -> str:
132132
'cache_dir': expand_path,
133133
'python_executable': expand_path,
134134
'strict': bool,
135-
'exclude': lambda s: [p.strip() for p in s.split('\n') if p.strip()],
135+
'exclude': lambda s: [s.strip()],
136136
}
137137

138138
# Reuse the ini_config_types and overwrite the diff

test-data/unit/cmdline.test

+4-3
Original file line numberDiff line numberDiff line change
@@ -1354,9 +1354,10 @@ b/bpkg.py:1: error: "int" not callable
13541354
# cmd: mypy .
13551355
[file mypy.ini]
13561356
\[mypy]
1357-
exclude =
1358-
abc
1359-
b
1357+
exclude = (?x)(
1358+
^abc/
1359+
|^b/
1360+
)
13601361
[file abc/apkg.py]
13611362
1()
13621363
[file b/bpkg.py]

0 commit comments

Comments
 (0)