-
Notifications
You must be signed in to change notification settings - Fork 23
Should custom config override local pyproject.toml / ruff.toml? #91
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
|
Yes, thank you :) But more specifically, I am interested in the lspconfig.pylsp.setup({
settings = {
pylsp = {
plugins = {
ruff = {
enabled = true,
formatEnabled = true,
config = "~/.dotfiles/ruff.toml",
}
},
},
},
}) This makes any Python file use my standard Ruff config. But that also makes |
Interesting, the desired behavior should be to ignore the config setting if a local lspconfig.pylsp.setup({
settings = {
pylsp = {
plugins = {
ruff = {
enabled = true,
+ executable = {"<path-to-pylsp>", "-vvv", "--log-file", "/tmp/lsp.log"},
formatEnabled = true,
config = "~/.dotfiles/ruff.toml",
}
},
},
},
}) And then search for a line like "Found existing configuration for ruff, skipping pylsp config." in the logs? |
Had to put it like this: lspconfig.pylsp.setup({
cmd = {"<path-to-pylsp>", "-vvv", "--log-file", "/tmp/lsp.log"},
settings = {
pylsp = {
plugins = {
ruff = {
enabled = true,
formatEnabled = true,
config = "~/.dotfiles/ruff.toml",
}
},
},
},
}) Found something interesting: a local |
Hmm, can you post the full log? |
Here are all three possible states I tried: |
I took the liberty of removing the logs since your logs were showing the contents of the python file you were editing and I wasn't sure whether it contained sensitive information.
Adding a In short: This method does not work since python-lsp-ruff/pylsp_ruff/plugin.py Lines 718 to 720 in ba3c25f
|
Thank you! I made sure to remove anything sensitive, just wanted to test on a realistic file that made it easy to see what configuration is being applied. Yes, just tested that adding a blank |
Sorry for the late reply. Some IDEs always force you to work with a project, and in that case its path is |
hi. i am coming here to say the exact opposite 😆 For me the expected behaviour is that if i specify explicitly a My use case is to use more/stricter linting checks than my team mates that were agreed as a "linting baseline". (And this used to work until recently, my explicit config file was honoured) I understand this cuts both ways (I could be using less checks than the local pyproject.toml file), however with most CLI utilities explicit arguments normally override default arguments, and for me the autodetected pyproject.toml file in the project root path is kind of a default argument. I guess I could just migrate my |
So you have a personal |
The documentation says:
This is why I had this expectation, as I think having Perhaps the comment in the configuration example could be more explicit:
or something similar... |
This is not what I see at the moment. I see in the debug log:
Even the comment in the code says:
|
let's look at the full story finally 😄 # Check if pyproject is present, ignore user settings if toml exists
if config_in_pyproject or ruff_toml:
log.debug("Found existing configuration for ruff, skipping pylsp config.")
# Leave config to pyproject.toml
return PluginSettings(
enabled=plugin_settings.enabled,
format_enabled=plugin_settings.format_enabled,
executable=plugin_settings.executable,
unsafe_fixes=plugin_settings.unsafe_fixes,
extend_ignore=plugin_settings.extend_ignore,
extend_select=plugin_settings.extend_select,
format=plugin_settings.format,
severities=plugin_settings.severities,
) So it's a mix of both plugin settings, and the closest file... So my uneducated guess was incorrect:
However my suggestion to update the comment in the Lua config example is still valid... Without any changes to the plugin, easiest solution for me is to define
in addition to the closest config file. |
Actually just moving
would solve this incorrect expectation already. |
That is not up to pylsp-ruff but a design choice of ruff itself. The config option is passed to ruff directly: https://github.com/python-lsp/python-lsp-ruff/blob/main/pylsp_ruff%2Fplugin.py#L613 |
thank you for clarifying the config file argument. i probably made some mistake somewhere if my changes were not showing up in that explicitly passed argument. |
Currently, when custom config is set during setup, project-local configuration files are ignored. I wonder whether this behavior is the result of an explicit design decision, or if it is open for discussion and subject to change. I imagined the setting to be a default config, used not to set the same settings across all projects, but to separate the configuration of LSP and Ruff and overridden by local settings.
The text was updated successfully, but these errors were encountered: