reddit / emacs

How to disable warnings in eglot/flymake/python?

rrdoa · 2022-06-18 22:31
I am currently using `lsp-mode` for Python. I want to try out eglot, but there is only one small issue. I get multiple warnings `pycodestyle [E501]: E501 line too long (84 > 79 characters)`. With `lsp-mode`, I could disable them in `.flake8` in my project. But it does not work with eglot/flymake. Any ideas to solve this? And how does the flymake integration work in `eglot`? Here is what I have tried: - `(setq python-flymake-command '("flake8" "-"))` - `(setq python-check-command "flake8")`
yapfff · 2022-06-19 08:01
This is not handled by eglot but by pycodestyle directly. Either use a pycodestyle project specific configuration, or a global user one. For example you could put into `~/.config/pycodestyle` the following: [pycodestyle] # Adjust to taste ;) max-line-length = 90 [pylsp] # The python language server used by eglot also use this config # file. So for example you can add stuff like: plugins.yapf.enabled: true And that's about it. For more info, check the pycodestyle documentation directly.
idspispopd0 · 2022-06-19 14:27
This. Also you can put special comments inside your files to ignore certain errors on particular lines if you want the linter to catch other unintentional syntax. For flake8, you add a comment with `# noqa: Exyz` where the `xyz` is the error code: https://flake8.pycqa.org/en/latest/user/violations.html#in-line-ignoring-errors
rrdoa · 2022-06-19 14:32
Thanks! It works with a config in `~/.config/pycodestyle`. I was under the impression that `flake8` was using `pycodestyle` itself. It there a way to tell `eglot` (or `flymake`) to use `flake8` instead? EDIT: I was able to get eglot to use `flake8` instead with this config: ``` (setq eglot-workspace-configuration ((pylsp (plugins (mccabe (enabled . nil)) ; Remove this if you want mccabe. (pycodestyle (enabled . nil)) (flake8 (enabled . t)))))) ``` Also, I had another issue. `flake8` would not recognize its config file in my project. This was because `eglot` was not running in the right directory. I used the `project-x` package to make `project.el` find the right root of my project.