Open
Description
Context
At our company, we configure the required-version
to a specific allowed version in pyproject.toml
like this:
[tool.ruff]
line-length = 150
required-version = "==0.9.3"
Issue
If you don't have ruff, or a different version installed, you get the following error notification:
0.005164375s ERROR ThreadId(04) ruff_server::session::index::ruff_settings: Failed to resolve settings for /Users/kasperzutterman/Desktop/ruff_issue/pyproject.toml: Required version `==0.9.3` does not match the running version `0.9.7`
The above is great behaviour, however the extension falls back to the ruff version packaged with the extension, and skips the configuration defined by pyproject.toml
.
This results in unintended formatting changes, that don't align with the company ruff configuration defined in pyproject.toml
Example
Below a minimal reproducible example:
Setup
# test.py
# Below line is 112 characters long, exceeding the 88 characters used as ruff default, but less than the line-length = 150 from pyproject.toml
example_line_too_long = ("value_1", "value_2", "value_3", "value_4", "value_5", "value_6", "value_7", "value_8")
With correct ruff version installed
uv venv --python=312
source .venv/bin/activate
uv pip install ruff==0.9.3
- in vscode:
>Ruff: format document
Result: no change, expected behaviour
Without ruff installed (or incorrect version)
- in vscode:
>Ruff: format document
Result: code reformatted, ignoring line-length = 150
defined by pyproject.toml
# Below line is 112 characters long, exceeding the 88 characters used as ruff default, but less than the line-length = 150 from pyproject.toml
example_line_too_long = (
"value_1",
"value_2",
"value_3",
"value_4",
"value_5",
"value_6",
"value_7",
"value_8",
)
Question
- Is this the intended behaviour?
- If Yes, is there any setting that can be used to prevent ruff from making any changes when no correct version is found?