MCPcopy Index your code
hub / github.com/python/mypy / expand_errors

Function expand_errors

mypy/test/data.py:539–565  ·  view source on GitHub ↗

Transform comments such as '# E: message' or '# E:3: message' in input. The result is lines like 'fnam:line: error: message'.

(input: list[str], output: list[str], fnam: str)

Source from the content-addressed store, hash-verified

537
538
539def expand_errors(input: list[str], output: list[str], fnam: str) -> None:
540 """Transform comments such as '# E: message' or
541 '# E:3: message' in input.
542
543 The result is lines like 'fnam:line: error: message'.
544 """
545
546 for i in range(len(input)):
547 # The first in the split things isn't a comment
548 for possible_err_comment in input[i].split(" # ")[1:]:
549 m = re.search(
550 r"^([ENW]):((?P<col>\d+):)? (?P<message>.*)$", possible_err_comment.strip()
551 )
552 if m:
553 if m.group(1) == "E":
554 severity = "error"
555 elif m.group(1) == "N":
556 severity = "note"
557 elif m.group(1) == "W":
558 severity = "warning"
559 col = m.group("col")
560 message = m.group("message")
561 message = message.replace("\\#", "#") # adds back escaped # character
562 if col is None:
563 output.append(f"{fnam}:{i + 1}: {severity}: {message}")
564 else:
565 output.append(f"{fnam}:{i + 1}:{col}: {severity}: {message}")
566
567
568def fix_win_path(line: str) -> str:

Callers 1

parse_test_caseFunction · 0.85

Calls 7

rangeClass · 0.85
lenFunction · 0.85
splitMethod · 0.80
stripMethod · 0.80
groupMethod · 0.80
replaceMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…