Ruff Syntax Errors reported as warnings
Issue
Newer versions of Ruff no longer return E999 for SyntaxError. Which means syntax errors are now getting reported as warnings instead of errors.
I'm not totally sure when it happened but I know it was returning "code": null, as early as version 0.5.7 (current is 0.11.13)
Example json output from ruff check --output-format=json ./syntax-error.py
[
{
"cell": null,
"code": null,
"end_location": {
"column": 1,
"row": 285
},
"filename": "/syntax-error.py",
"fix": null,
"location": {
"column": 17,
"row": 284
},
"message": "SyntaxError: Expected ':', found newline",
"noqa_row": null,
"url": null
}
]
Ruff documentation mentions this change.
Looks like the message would need to be parsed for SyntaxError if code is null to set the correct severity.
Added a fix in the ruff.lua linter to check for SyntaxError in message. I tested it locally and SyntaxError correctly reported as Error severity. Let me know if there is anything you'd want done differently in the PR.
Thanks - I wonder a bit if an absent code could always be treated as error, but merged this for now