-
Notifications
You must be signed in to change notification settings - Fork 23
Auto-disabling flake8 doesn't seem possible #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This behaviour is intended, since any configuration you pass to the LSP server should not be superseded by the configuration of any of the plugins. Let me rewrite your problem to make sure I understand: In the case of Feel free to open a feature request here if this doesn't solve your issue. |
Hey! Thanks for getting back to me so quickly.
Yes, you've got it 100%.
Makes total sense, thanks. In that case, if I submit a PR that removes flake8 from the list of auto-disabled plugins then would you consider merging it? It might save someone else from going doing the rabbit hole of "if this is documented then there must be a way for it to work!". I can also add a sentence to clarify "Plugins that are explicitly enabled in the pylsp configuration can't be auto-disabled."
Ruff doesn't load flake8's config files. However, it seems like more and more projects are standardising on Ruff, for good reasons. So the problem might solve itself that way. :) |
I know the pain of going through the LSP logs, so I think it's a nice idea to remove flake8 (and all other plugins that are auto-disabled by default) from this list. Feel free to submit the PR and I'll merge it when ready. |
flake8 plugin is disabled by default. If it's been enabled in the pylsp configuration then it's not possible for another plugin to disable it. The other four plugins (pycodestyle, pyflakes, mccabe, pyls_isort) are all enabled by default so the ruff plugin can disable them, provided they're not explicitly enabled in the configuration. Closes python-lsp#46
flake8 plugin is disabled by default. If it's been enabled in the pylsp configuration then it's not possible for another plugin to disable it. The other four plugins (pycodestyle, pyflakes, mccabe, pyls_isort) are all enabled by default so the ruff plugin can disable them, provided they're not explicitly enabled in the configuration. Closes #46
If the client configuration contains
pylsp.plugins.flake8.enabled = true
(which is necessary for flake8 to enable in pylsp), then this seems to always override the documented python-lsp-ruff behaviour of auto-disabling flake8.I think this applies for all the linters that are auto-disabled by python-lsp-ruff, although in the other cases they are enabled by default so leaving
enabled = true
out of the client config will solve the problem.What I observe with my LSP client (eglot) is the following sequence of events:
initialize
python-lsp-ruff
andflake8_lint
.pylsp_settings
hook. It will merge'flake8': {'enabled': False}
into the plugins settings (along with the same for other other auto-disabled plugins.)pylsp_settings
hook, which also sets'flake8': {'enabled': False}
(not sure if these happen in a guaranteed order, but the outcome is the same - flake8 is definitely disabled!)pylsp -v
will log aDisabled plugins:
line that includespylsp.plugins.flake8_lint
.'workspace/didChangeConfiguration'
with'params': {'settings': {'pylsp': {'plugins': [...] 'flake8': {'enabled': True} [...]
pylsp -v
will log aDisabled plugins:
line that no longer includespylsp.plugins.flake8_lint
.This may be an eglot bug(?) but from what I've seen it seems likely most clients will send these events in this sequence.
Workarounds
flake8
binary on the PATH of the venv works, as then the plugin enables but never produces any results.didChangeConfiguration
. However this seems counter to the overall architecture of LSP, where the language-specific implementation is delegated to the server.Idea for fix
The best idea I've come up with for a fix would actually be a python-lsp feature, not a python-lsp-ruff change. Although hopefully there's a simpler way to solve this in python-lsp-ruff, I'm pretty unfamiliar with LSP.
The idea is, pylsp could support a setting like
pylsp.plugins.NAME.enabled = 'project'
setting that will call a hook in the plugin that checks for the configuration files or keys used by that plugin's linter in the project, and only enables the plugin if some configuration is found. Most of this logic already exists in the plugins.If this does seem like a good feature then I'm happy to raise it on the main pylsp repo, and potentially raise some PRs.
The text was updated successfully, but these errors were encountered: