flymake-ruff
flymake-ruff copied to clipboard
flymake plugin for ruff linter
flymake-ruff
Flymake plugin to run a linter for python buffers using ruff
Make sure you have at least
ruff
0.1.0
version because there is a breaking change in the output format flag
Installation
Cloning the repo
Clone this repo somewhere, and add this to your config:
(add-to-list 'load-path "path where the repo was cloned")
(require 'flymake-ruff)
(add-hook 'python-mode-hook #'flymake-ruff-load)
Using use-package
(use-package flymake-ruff
:ensure t
:hook (python-mode . flymake-ruff-load))
Using straight.el
(use-package flymake-ruff
:straight (flymake-ruff
:type git
:host github
:repo "erickgnavar/flymake-ruff"))
Using flymake-ruff with eglot
To use flymake-ruff together with eglot, you should add flymake-ruff-load
to
eglot-managed-mode-hook
instead. For example:
(add-hook 'eglot-managed-mode-hook 'flymake-ruff-load)
Or, if you use use-package:
(use-package flymake-ruff
:ensure t
:hook (eglot-managed-mode . flymake-ruff-load))
Excluding Pyright diagnostic notes
Pyright has some diagnostic notes that overlap with diagnostics provided by
ruff. These diagnostic notes can't be disabled via Pyright's config, but you can
exclude them by adding a filter to eglot--report-to-flymake
. For example, to
remove Pyright's "variable not accessed" notes, add the following:
(defun my-filter-eglot-diagnostics (diags)
"Drop Pyright 'variable not accessed' notes from DIAGS."
(list (seq-remove (lambda (d)
(and (eq (flymake-diagnostic-type d) 'eglot-note)
(s-starts-with? "Pyright:" (flymake-diagnostic-text d))
(s-ends-with? "is not accessed" (flymake-diagnostic-text d))))
(car diags))))
(advice-add 'eglot--report-to-flymake :filter-args #'my-filter-eglot-diagnostics))