Skip to content

Commit

Permalink
Add flymake-ruff for Python
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Nov 1, 2023
1 parent 8c7aaff commit 49d4940
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lisp/init-python.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

(require-package 'pip-requirements)

(when (maybe-require-package 'flymake-ruff)
(defun sanityinc/flymake-ruff-maybe-enable ()
(when (executable-find flymake-ruff-program)
(flymake-ruff-load)))
(add-hook 'python-mode-hook 'sanityinc/flymake-ruff-maybe-enable))

(when (maybe-require-package 'toml-mode)
(add-to-list 'auto-mode-alist '("poetry\\.lock\\'" . toml-mode)))

Expand Down

2 comments on commit 49d4940

@doolio
Copy link

@doolio doolio commented on 49d4940 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could also set python-flymake-command to something like "ruff" "--quiet" "--stdin-filename=stdin" "-", no? The only drawback I've found is it doesn't include a ruff prefix in the error messages to identify them as ruff reported errors. Also, ruff includes a format command as a drop-in replacement for black.

@purcell
Copy link
Owner Author

@purcell purcell commented on 49d4940 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could also set python-flymake-command to something like "ruff" "--quiet" "--stdin-filename=stdin" "-", no?

Maybe. I mean, I'm not using this myself yet, so feel free to add local configuration that fits your preferences. It seems like there are a few ways to use it.

Please sign in to comment.