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]