Python switch to black and flake8 for ruff (+ isort)
Add black profile option to isort formatter call Keep option for flake8 as checker if ruff not available (e.g. on another machine)
This commit is contained in:
parent
2fc42e3eea
commit
178456df06
15
init.el
15
init.el
|
@ -926,9 +926,10 @@
|
||||||
:custom (apheleia-remote-algorithm 'local)
|
:custom (apheleia-remote-algorithm 'local)
|
||||||
:config
|
:config
|
||||||
(add-to-list 'apheleia-formatters '(alejandra . ("alejandra")))
|
(add-to-list 'apheleia-formatters '(alejandra . ("alejandra")))
|
||||||
|
(add-to-list 'apheleia-formatters '(isort . ("isort" "--profile" "black" "-")))
|
||||||
(add-to-list 'apheleia-mode-alist '(nix-mode . alejandra))
|
(add-to-list 'apheleia-mode-alist '(nix-mode . alejandra))
|
||||||
(add-to-list 'apheleia-mode-alist '(python-mode . (black isort)))
|
(add-to-list 'apheleia-mode-alist '(python-mode . (ruff isort)))
|
||||||
(add-to-list 'apheleia-mode-alist '(python-ts-mode . (black isort))))
|
(add-to-list 'apheleia-mode-alist '(python-ts-mode . (ruff isort))))
|
||||||
|
|
||||||
(use-package flymake
|
(use-package flymake
|
||||||
:bind (("C-c C-." . flymake-goto-next-error)
|
:bind (("C-c C-." . flymake-goto-next-error)
|
||||||
|
@ -1025,15 +1026,15 @@ Calls `project-remember-project-under' for ~/.config/,
|
||||||
|
|
||||||
(use-package python
|
(use-package python
|
||||||
:hook ((python-base-mode . (lambda () (my/enable-fill-column 88)))
|
:hook ((python-base-mode . (lambda () (my/enable-fill-column 88)))
|
||||||
(python-base-mode . (lambda () (add-hook 'flymake-diagnostic-functions
|
(python-base-mode . (lambda () (add-hook 'flymake-diagnostic-functions 'flymake-collection-mypy nil t))))
|
||||||
'flymake-collection-mypy nil t))))
|
|
||||||
:custom
|
:custom
|
||||||
;; Set max line length for compatibility with black formatter
|
|
||||||
(python-flymake-command
|
(python-flymake-command
|
||||||
(cond ((executable-find "flake8") '("flake8" "--max-line-length" "88" "-"))
|
(cond ((executable-find "ruff") ("ruff" "check" "--output-format" "pylint" "-"))
|
||||||
|
((executable-find "flake8") ("flake8" "--max-line-length" "88" "-"))
|
||||||
(t ("pyflakes"))))
|
(t ("pyflakes"))))
|
||||||
(python-check-command
|
(python-check-command
|
||||||
(cond ((executable-find "flake8") "flake8 --max-line-length 88")
|
(cond ((executable-find "ruff") "ruff check --output-format pylint")
|
||||||
|
((executable-find "flake8") "flake8 --max-line-length 88")
|
||||||
(t "pyflakes")))
|
(t "pyflakes")))
|
||||||
:config
|
:config
|
||||||
(setq python-ts-mode-hook python-mode-hook))
|
(setq python-ts-mode-hook python-mode-hook))
|
||||||
|
|
Loading…
Reference in a new issue