From 87b76e721944b0310e0153090426c2f1726bae9c Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Sun, 5 Apr 2026 08:00:07 -0500 Subject: [PATCH 1/3] add succeeding test and failing test relevant to feature --- mypy/test/meta/test_parse_data.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mypy/test/meta/test_parse_data.py b/mypy/test/meta/test_parse_data.py index 07343414293c2..c891e958f7a78 100644 --- a/mypy/test/meta/test_parse_data.py +++ b/mypy/test/meta/test_parse_data.py @@ -67,3 +67,26 @@ def test_bad_eq_version_check(self) -> None: assert ( "version==3.7 always false since minimum runtime version is (3, 10)" in actual.stdout ) + + def test_typical_error_comment(self) -> None: + # Act + actual = _run_pytest(""" + [case abc] + a # E: typical-looking error comment + """) + + # Assert + assert ( + "typical-looking error comment" in actual.stderr + ) + def test_lineleading_error_comment(self) -> None: + # Act + actual = _run_pytest(""" + [case abc] + # E: line-leading error comment + """) + + # Assert + assert ( + "line-leading error comment" in actual.stderr + ) From 33e732bbe8c1f97dd79e0d2a5c7d11028930b5f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 Apr 2026 13:04:52 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/test/meta/test_parse_data.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mypy/test/meta/test_parse_data.py b/mypy/test/meta/test_parse_data.py index c891e958f7a78..47324098b0e04 100644 --- a/mypy/test/meta/test_parse_data.py +++ b/mypy/test/meta/test_parse_data.py @@ -76,9 +76,8 @@ def test_typical_error_comment(self) -> None: """) # Assert - assert ( - "typical-looking error comment" in actual.stderr - ) + assert "typical-looking error comment" in actual.stderr + def test_lineleading_error_comment(self) -> None: # Act actual = _run_pytest(""" @@ -87,6 +86,4 @@ def test_lineleading_error_comment(self) -> None: """) # Assert - assert ( - "line-leading error comment" in actual.stderr - ) + assert "line-leading error comment" in actual.stderr From 1ed3f49bd81f4b5ec00ec6ffae7598f70aa56647 Mon Sep 17 00:00:00 2001 From: wyattscarpenter Date: Sun, 5 Apr 2026 08:10:07 -0500 Subject: [PATCH 3/3] fix the issue --- mypy/test/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/test/data.py b/mypy/test/data.py index 30e4ef95adc85..d5ed644b4b474 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -545,7 +545,7 @@ def expand_errors(input: list[str], output: list[str], fnam: str) -> None: for i in range(len(input)): # The first in the split things isn't a comment - for possible_err_comment in input[i].split(" # ")[1:]: + for possible_err_comment in re.split("(?:^| )# ", input[i])[1:]: m = re.search( r"^([ENW]):((?P\d+):)? (?P.*)$", possible_err_comment.strip() )