File tree 3 files changed +20
-9
lines changed
3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -197,18 +197,28 @@ section of the command line docs.
197
197
198
198
.. confval :: exclude
199
199
200
- :type: newline separated list of regular expressions
200
+ :type: regular expression
201
201
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
203
203
which mypy should ignore while recursively discovering files to check.
204
204
Use forward slashes on all platforms.
205
205
206
206
.. code-block :: ini
207
207
208
208
[mypy]
209
- exclude =
210
- ^file1\.py$
211
- ^file2\.py$
209
+ exclude = (?x)(
210
+ ^one\.py$ # files named "one.py"
211
+ | two\.pyi$ # or files ending with "two.pyi"
212
+ | ^three\. # or files starting with "three."
213
+ )
214
+
215
+ Crafting a single regular expression that excludes multiple files while remaining
216
+ human-readable can be a challenge. The above example demonstrates one approach.
217
+ ``(?x) `` enables the ``VERBOSE `` flag for the subsequent regular expression, which
218
+ `ignores most whitespace and supports comments `__. The above is equivalent to:
219
+ ``(^one\.py$|two\.pyi$|^three\.) ``.
220
+
221
+ .. __ : https://docs.python.org/3/library/re.html#re.X
212
222
213
223
For more details, see :option: `--exclude <mypy --exclude> `.
214
224
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ def check_follow_imports(choice: str) -> str:
132
132
'cache_dir' : expand_path ,
133
133
'python_executable' : expand_path ,
134
134
'strict' : bool ,
135
- 'exclude' : lambda s : [p . strip () for p in s . split ( ' \n ' ) if p .strip ()],
135
+ 'exclude' : lambda s : [s .strip ()],
136
136
}
137
137
138
138
# Reuse the ini_config_types and overwrite the diff
Original file line number Diff line number Diff line change @@ -1354,9 +1354,10 @@ b/bpkg.py:1: error: "int" not callable
1354
1354
# cmd: mypy .
1355
1355
[file mypy.ini]
1356
1356
\[mypy]
1357
- exclude =
1358
- abc
1359
- b
1357
+ exclude = (?x)(
1358
+ ^abc/
1359
+ |^b/
1360
+ )
1360
1361
[file abc/apkg.py]
1361
1362
1()
1362
1363
[file b/bpkg.py]
You can’t perform that action at this time.
0 commit comments