Skip to content

Commit c4c9764

Browse files
authored
Fix error code handling in native parser (#20952)
Currently few tests cases crash with native parser because of this (and it wasn't caught because we still use `dict[str, Any]` in various places).
1 parent d8d8dca commit c4c9764

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

mypy/parse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def parse(
5555
error_code = error.get("code")
5656
if error_code is None:
5757
error_code = codes.SYNTAX
58+
else:
59+
# Fallback to [syntax] for backwards compatibility.
60+
error_code = codes.error_codes.get(error_code) or codes.SYNTAX
5861
errors.report(
5962
error["line"], error["column"], message, blocker=is_blocker, code=error_code
6063
)

0 commit comments

Comments
 (0)