Skip to content

Commit ba6afdb

Browse files
be more strict, but also more lenient, about error code comment format
1 parent 59a14cb commit ba6afdb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mypy/test/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ def expand_errors(input: list[str], output: list[str], fnam: str) -> None:
533533

534534
for i in range(len(input)):
535535
# The first in the split things isn't a comment
536-
for possible_err_comment in re.split(r"(?!\\)#", input[i])[1:]:
536+
for possible_err_comment in re.split(r"(?!\\)#\s*(?=[ENW]\s*:)", input[i])[1:]:
537537
m = re.search(
538-
r"^([ENW]):((?P<col>\d+):)? (?P<message>.*)$", possible_err_comment.strip()
538+
r"^([ENW])\s*:((?P<col>\d+):)?\s*(?P<message>.*)$", possible_err_comment.strip()
539539
)
540540
if m:
541541
if m.group(1) == "E":

mypy/test/update_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _iter_fixes(
6464
fix_lines = []
6565
for lineno, source_line in enumerate(source_lines, start=1):
6666
reports = reports_by_line.get((file_path, lineno))
67-
comment_match = re.search(r"(?P<indent>\s+)(?P<comment># ?[EWN]: .+)$", source_line)
67+
comment_match = re.search(r"(?P<indent>\s+)(?P<comment>#\s*[EWN]\s*:.+)$", source_line)
6868
if comment_match:
6969
source_line = source_line[: comment_match.start("indent")] # strip old comment
7070
if reports:

0 commit comments

Comments
 (0)