nvim-lint icon indicating copy to clipboard operation
nvim-lint copied to clipboard

Ruff Syntax Errors reported as warnings

Open nagibyro opened this issue 6 months ago • 1 comments

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.

nagibyro avatar Jun 17 '25 01:06 nagibyro

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.

nagibyro avatar Jun 17 '25 02:06 nagibyro

Thanks - I wonder a bit if an absent code could always be treated as error, but merged this for now

mfussenegger avatar Jul 04 '25 08:07 mfussenegger