Skip to content
/ mypy Public
forked from python/mypy

Commit

Permalink
Revert to treating exclude in .ini as single string
Browse files Browse the repository at this point in the history
Fixes python#11830. Depends on python#11828.
  • Loading branch information
posita committed Jan 1, 2022
1 parent bbd5431 commit b8d3b6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions docs/source/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,19 @@ section of the command line docs.

.. confval:: exclude

:type: newline separated list of regular expressions
:type: regular expressions

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

.. code-block:: ini
[mypy]
exclude =
exclude = (?x)(
^file1\.py$
^file2\.py$
|^file2\.py$
)
For more details, see :option:`--exclude <mypy --exclude>`.

Expand Down Expand Up @@ -997,8 +998,8 @@ of your repo (or append it to the end of an existing ``pyproject.toml`` file) an
warn_return_any = true
warn_unused_configs = true
exclude = [
'^file1\.py$', # TOML single-quoted string (no escaping necessary)
"^file2\\.py$", # TOML double-quoted string (backslash needs escaping)
'^file1\.py$', # TOML literal string (single quotes, no escaping necessary)
"^file2\\.py$", # TOML basic string (double quotes, backslash and other characters need escaping)
]
# mypy per-module options:
Expand Down
2 changes: 1 addition & 1 deletion mypy/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def check_follow_imports(choice: str) -> str:
'cache_dir': expand_path,
'python_executable': expand_path,
'strict': bool,
'exclude': lambda s: [p.strip() for p in s.split('\n') if p.strip()],
'exclude': lambda s: [s.strip()],
}

# Reuse the ini_config_types and overwrite the diff
Expand Down
7 changes: 4 additions & 3 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -1354,9 +1354,10 @@ b/bpkg.py:1: error: "int" not callable
# cmd: mypy .
[file mypy.ini]
\[mypy]
exclude =
abc
b
exclude = (?x)(
^abc/
|^b/
)
[file abc/apkg.py]
1()
[file b/bpkg.py]
Expand Down

0 comments on commit b8d3b6c

Please sign in to comment.