-
-
Save dsedivec/65eff752ec3aa3b652977c6e681bd609 to your computer and use it in GitHub Desktop.
Emacs ruff flycheck config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'flycheck) | |
;; From https://github.com/flycheck/flycheck/issues/1974#issuecomment-1343495202 | |
(flycheck-define-checker python-ruff | |
"A Python syntax and style checker using the ruff utility. | |
To override the path to the ruff executable, set | |
`flycheck-python-ruff-executable'. | |
See URL `http://pypi.python.org/pypi/ruff'." | |
:command ("ruff" | |
"check" | |
"--output-format=text" | |
(eval (when buffer-file-name | |
(concat "--stdin-filename=" buffer-file-name))) | |
"-") | |
:standard-input t | |
:error-filter (lambda (errors) | |
(let ((errors (flycheck-sanitize-errors errors))) | |
(seq-map #'flycheck-flake8-fix-error-level errors))) | |
:error-patterns | |
((warning line-start | |
(file-name) ":" line ":" (optional column ":") " " | |
(id (one-or-more (any alpha)) (one-or-more digit)) " " | |
(message (one-or-more not-newline)) | |
line-end)) | |
:modes (python-mode python-ts-mode)) | |
;; Use something adapted to your config to add `python-ruff' to `flycheck-checkers' | |
;; This is an MVP example: | |
(setq python-mode-hook | |
(list (defun my-python-hook () | |
(unless (bound-and-true-p org-src-mode) | |
(when (buffer-file-name) | |
(setq-local flycheck-checkers '(python-ruff)) | |
(flycheck-mode)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind, the problem was I apparently had ruff installed with both pip and homebrew so it was using the pip version which was very out of date. So adding the homebrew one to the exec path fixed the issue. Thank you for the help!