-
Notifications
You must be signed in to change notification settings - Fork 57
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
priority between pyproject.toml ignore=[...] and --extend-select? #515
Comments
Are you using |
I am using whatever is the default, i.e. currently not the new Rust-based native server. The only Ruff-specific setting in our (Dev container-based) settings is |
My expectation then is that the configuration you described should behave the way you want. I can give it a try myself. |
The documentation for this is at https://docs.astral.sh/ruff/linter/#rule-selection, specifically this line:
I agree that it's a bit hidden. I can confirm that it should work with the following settings: VS Code {
"ruff.nativeServer": false,
"ruff.lint.args": [
"--extend-select=E501"
],
} And, [tool.ruff]
line-length = 30
[tool.ruff.lint]
ignore = ["E501"] ![]() And, if I comment out the |
Can you specify what exactly isn't happening? Is it either the CI or the editor that is not warning about |
@dhruvmanila: The VSCode editor is not warning about overlong lines. Thank you all for looking at this and for clarifying that it is supposed to work as I had hoped, and for pointing me at the relevant documentation. I will investigate some more to verify that this is not just PEBKAC on my part. Also, my use case is in a devcontainer, and I have noticed some other problems with that setup, so perhaps it is a devcontainer-only problem. In either case, it would be good if the documentation was more "in your face", i.e. less hidden, about what to expect when combining (conflicting) options. |
Sorry, I wasn't aware that the problem you're facing is in a devcontainer. As you've noticed, there have been some reports around Ruff running in devcontainer.
I hear you. In this case, I think a bulleted list would help. Thank you for the feedback! |
The plot thickens. I changed our The
What seems to happen is that the In the terminal, on the devcontainer, I have:
So, the I look at the OUTPUT tab in VSCode, and the following replicates how
I.e. If I add |
I think I see the problem in here. The {
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"charliermarsh.ruff",
"redhat.ansible"
],
"settings": {
"extensions.verifySignature": false,
"telemetry.enableTelemetry": false,
"python.defaultInterpreterPath": "${workspaceFolder}/.venv",
"git.autoRepositoryDetection": true,
"git.openRepositoryInParentFolders": "always",
// Ruff settings should be in the global namespace
"ruff.nativeServer": false,
"ruff.lint.args": [
"--extend-select=E501"
],
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
}
}
}
}
} Can you try this? I think this should work now. |
Thanks for the workaround! I can confirm that if I put the Interestingly, unlike some other settings (#501), even after disconnecting and re-connecting to the dev container, putting However, this is not documented, I think, and surely this is unexpected and a bug? (Given the problems mentioned in #501 it may be a bug in the VSCode dev-container plugin, I have no idea how VSCode works internally) |
Good to know it's working :)
The extension settings are not part of the language namespace which is why you can't use it in there. This is a deliberate choice. Ruff only works with the Python language so there's no benefit in reading these settings from the language namespace unlike other settings like
Can you specify what isn't documented? I don't this is unexpected nor a bug for the same reasons as stated in the previous paragraph. |
My expectation would be that every plugin looks up any setting hierarchically, from more specific (e.g for a particular language) to less specific (i.e. global scope in This way I do not need to know whether a plugin (like If plugins always looked for their setting hierarchically like this, my settings would be future safe, e.g. if It also makes it possible to keep the (But, as I mentioned, I have no idea how VSCode plugins are supposed to work, the above is just what I expected.) |
That's interesting. Out of curiosity, do you know any plugin that actually does resolve the settings like the way you've mentioned? I don't think I know any extension which does that. (I'll close this issue considering it resolved.) |
If the
pyproject.toml
haveignore = [ "E501" ]
, andruff
is invoked (by the VSCode plugin v2024.30.0), with--extend-select=E501
, the documentation does not say "who will win", i.e. whetherE501
issues will be reported.I looked at Configuring VSCode and Configuring Ruff but it has no information about how conflicting options are resolved.
I do not know whether this is "just" missing documentation, or whether this is a bug in behavior.
In our case, we would like the CI (which only uses
pyproject.toml
) to ignoreE501
(overlong lines) but we want the VSCode linter to warn aboutE501
, so we would prefer that--extend-select
overrides any settings inpyproject.toml
but that does not seem to be what it happening.The text was updated successfully, but these errors were encountered: