From 45f5157b12bc20ba29d002d1cde58b6852cc5ed4 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 6 Feb 2025 19:39:48 +0300 Subject: [PATCH] Allow trailing commas for `files` setting in `mypy.ini` and `setup.ini` --- mypy/config_parser.py | 2 +- test-data/unit/cmdline.test | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index c68efe9e44ef..94427a347779 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -126,7 +126,7 @@ def split_and_match_files(paths: str) -> list[str]: Returns a list of file paths """ - return split_and_match_files_list(paths.split(",")) + return split_and_match_files_list(split_commas(paths)) def check_follow_imports(choice: str) -> str: diff --git a/test-data/unit/cmdline.test b/test-data/unit/cmdline.test index 2c53266866f4..f298f6dbe2df 100644 --- a/test-data/unit/cmdline.test +++ b/test-data/unit/cmdline.test @@ -1300,6 +1300,22 @@ foo.py:1: error: "int" not callable [out] foo/m.py:1: error: "int" not callable +[case testCmdlineCfgFilesTrailingComma] +# cmd: mypy +[file mypy.ini] +\[mypy] +files = + a.py, + b.py, +[file a.py] +x: str = 'x' # ok +[file b.py] +y: int = 'y' # E: Incompatible types in assignment (expression has type "str", variable has type "int") +[file c.py] +# This should not trigger any errors, because it is not included: +z: int = 'z' +[out] + [case testCmdlineCfgEnableErrorCodeTrailingComma] # cmd: mypy . [file mypy.ini]