-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserves interpreting multi-line strings as a single value for exclude
in TOML files
#11828
Preserves interpreting multi-line strings as a single value for exclude
in TOML files
#11828
Conversation
0fd2c8e
to
f483ee1
Compare
exclude
as a multi-line basic string in TOML files
mypy/config_parser.py
Outdated
@@ -143,6 +149,7 @@ def check_follow_imports(choice: str) -> str: | |||
'disable_error_code': try_split, | |||
'enable_error_code': try_split, | |||
'package_root': try_split, | |||
'exclude': str_or_seq_of_strs_as_list_of_strs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name is a bit verbose. I'm open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed and don't have a supremely better idea. Maybe into_list
- implying that list
is the result, but not implying that splitting is happening.
exclude
as a multi-line basic string in TOML filesexclude
in TOML files
This looks great! |
f483ee1
to
66c0b7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments cleared or not?
docs/source/config_file.rst
Outdated
[tool.mypy] | ||
exclude = [ | ||
'^file1\.py$', # literal (no escaping) | ||
"^file2\\.py$", # basic (backslash needs escaping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"^file2\\.py$", # basic (backslash needs escaping) | |
"^windows_dir\\file2\.py$", # a literal backslash should be escaped with a backslash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above.
Multiple regexes are expressed as a sequence. Fixes python#11825.
66c0b7d
to
bbd5431
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
Thank you @posita and @mawillcockson for fixing this!
I brought this up in #11700, so hopefully we get a 0.931 that adds this (and whatever we decide for #11830)
Co-authored-by: Matthew W <[email protected]>
Fixes python#11830. Depends on python#11828.
@hauntsaninja, see #11881 and this comment (in case you wanted to update this). |
Thank you for fixing this! |
…ude` in TOML files (#11828) Multiple regexes are expressed as a sequence. Fixes #11825. Co-authored-by: Matthew W <[email protected]> Co-authored-by: Shantanu <[email protected]>
…ude` in TOML files (python#11828) Multiple regexes are expressed as a sequence. Fixes python#11825. Co-authored-by: Matthew W <[email protected]> Co-authored-by: Shantanu <[email protected]>
Introduces an alternative where multiple regexes can be expressed as an array. Includes additional unit tests.
This preserves backward compatibility by allowing multi-line values in TOML to be treated as a single regex for those who have come to rely on that while exposing an array-based expression as a more ergonomic (and TOML-like) alternative.
Fixes #11825. Obsoletes (or is obsoleted by) #11746.