reddit / emacs

LSP with pyright and flake8

Only-Adhesiveness889 · 2022-07-28 11:34
Hi everyone, yet another LSP question. I am hoping that someone with a similar setup can help me configuring things correctly. I am using `pyright` with `lsp-mode` (via `lsp-pyright`) and want to switch the `flycheck` checker to `flake8`. After some fiddling I got things to kind of work by setting (setq flycheck-python-flake8-executable "flake8") (setq-default flycheck-disabled-checkers '(lsp)) in my config. I say kind of, because the errors that are underlined in the buffer are chosen by `flake8` and jumping between them with the flycheck commands works. However, `M-x flycheck-verify-setup` gives me Syntax checkers for buffer iosys.py in python-mode: No checker to run in this buffer. Checkers that could run if selected: python-flake8 select - may enable: yes - executable: Found at /Users/pelling/miniconda3/envs/pymor/bin/flake8 - configuration file: Found at "/Users/pelling/projects/pymor/setup.cfg" - next checkers: python-pylint, python-mypy python-pycompile select - may enable: yes - executable: Found at /Users/pelling/miniconda3/envs/pymor/bin/python3 - next checkers: python-mypy python-pyright select - may enable: yes - executable: Found at /Users/pelling/miniconda3/envs/pymor/bin/pyright Checkers that are compatible with this mode, but will not run until properly configured: lsp (manually disabled) enable (explicitly selected) - may enable: yes - may run: t python-pylint (automatically disabled) reset - may enable: no - executable: Not found - configuration file: Found at "/Users/pelling/projects/pymor/pyproject.toml" - next checkers: python-mypy python-mypy (automatically disabled) reset - may enable: no - may run: t - executable: Not found - configuration file: Found at "/Users/pelling/projects/pymor/pyproject.toml" Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers. -------------------- Flycheck version: 32snapshot Emacs version: 28.1 System: aarch64-apple-darwin21.5.0 Window system: ns which says `(explicitly selected)` after `lsp` and my modeline shows a lot of errors. When I look at them with `lsp-ui-flycheck-list` they are all errors detected from `pyright`. ​ Any ideas on how I can avoid this double checking and achieve what I want (only check errors with `flake8)` are greatly appreciated. I don't quite understand the interplay between pyright, lsp-ui and flycheck...
shaqfooVA · 2022-07-28 14:57
I use this to disable all python checkers other than flake8 (and mypy in a dir local basis) `(setq flycheck-checkers (remove 'python-pylint flycheck-checkers)) (setq flycheck-checkers (remove 'python-pycompile flycheck-checkers)) (setq flycheck-checkers (remove 'python-pyright flycheck-checkers))`
janoc · 2022-07-28 20:39
I use: In the `python-mode` hook: (setq flycheck-enabled-checkers '(python-flake8 python-mypy)) (setq flycheck-disabled-checkers '(python-pylint) (flycheck-select-checker 'python-flake8) And for lsp: (setq lsp-diagnostics-provider :auto) The above should set the diagnostics to be taken from `flycheck` or `flymake` instead of `lsp` running its own copy of `flake8`. However, `flycheck` is still set to have `lsp` as checker, I don't have it disabled.