erickgnavar / flymake-ruff

flymake plugin for ruff linter
GNU General Public License v3.0
37 stars 6 forks source link

Update output regex to work with newer versions #19

Closed biscanli closed 1 month ago

biscanli commented 1 month ago

Hello!

This PR aims to get the ruff output from version 0.6.9 (which is the latest as of writing this) working with flymake-ruff. I tested it on my local machine but feel free to give it a poke yourself ,and let me know if anything else needs changing.

Btw, thanks for the package!

erickgnavar commented 1 month ago

Hi, thanks for your contribution, do you have any example that doesn't work with newest version of ruff? I can't see any breaking changes in the changelog 🤔

biscanli commented 1 month ago

Sure! I ran it on a.py which had:

from import as

b = 5

In Emacs I didn't get errors, so I ran the ruff command on this file from the CLI, I got

a.py:1:6: SyntaxError: Expected a module name
a.py:1:13: SyntaxError: Expected an import name

Once I changed the regexp to the one in PR, it started working again.

erickgnavar commented 1 month ago

Oh I see it now, it's for syntax errors, those are not linting errors per se but it might be good to see them. I tested the change and works partially, make sure to define : as optional so it still works for previous rules

I suggest this change

-(defvar flymake-ruff--output-regex "\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\([A-Za-z0-9]+\\): \\(.*\\)")
+(defvar flymake-ruff--output-regex "\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\([A-Za-z0-9]+\\):? \\(.*\\)")
biscanli commented 1 month ago

Nice catch! Just tested it and it works as I expect it, pushing it now.