Unable to set specific ignore rules
sho-87 opened this issue · 5 comments
I'm running emacs with lsp-mode, and have pylsp set up with this plugin
I'm having an issue setting specific ignore rules. for example:
(lsp-register-custom-settings '(
("pylsp.plugins.ruff.enabled" t)
("pylsp.plugins.ruff.lineLength" 88)
("pylsp.plugins.ruff.ignore" "D215")
))
I get this error:
ERROR - pylsp_ruff.plugin - Error running ruff: error: invalid value '2' for '--ignore <RULE_CODE>'
But if I change my config to use the more general D category ("pylsp.plugins.ruff.ignore" "D")
instead of a specific rule then everything works fine
I just tried this in neovim, and the following works:
ruff = {
enabled = true,
ignore = { "D215" },
},
I'm explicitly casting to an array-type here.
I'm no eLisp expert here, but it seems that pylsp receives D215
as a char-array type (which is why 2
is passed individually)
Have you tried putting it into a Vector Type? (ref: https://www.gnu.org/software/emacs/manual/html_node/elisp/Vector-Type.html)
(lsp-register-custom-settings '(
("pylsp.plugins.ruff.enabled" t)
("pylsp.plugins.ruff.lineLength" 88)
("pylsp.plugins.ruff.ignore" ["D215"])
))
yeah that was one of the first things I tried: pylsp.plugins.ruff.ignore" ["D215", "D103"])
, but I get a similar error:
ERROR - pylsp_ruff.plugin - Error running ruff: error: invalid value '{'' for '--ignore <RULE_CODE>'
In this case its strange because I'm not even using {
anywhere, so somewhere along the way between lsp-mode -> pylsp -> lsp-ruff the type is being converted to {}
, but unsure how to figure out where exactly the issue is coming from
(side note: the reason I ended up with the "D215,D103,..." format was because the error suggests the codes are being passed directly into --ignore
, which from what I read in the ruff documentation expects just a comma separated list of codes. For example, running ruff --ignore D215,D103
directly in the cli seems to work)
Going through https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-pylsp.el I noticed that use this defcustom
to configure the lsp, maybe try to define those and then pass them instead of directly trying to pass the string?
Also check out that there exists some kind of generation script for the configuration settings: https://emacs-lsp.github.io/lsp-mode/page/adding-new-language/#sections