-
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
Consider required-version
when finding the ruff
binary
#701
Comments
Perhaps a third importStrategy as mentioned by this issue would help fix this: #655 |
Thanks for the detailed write up. I'm not sure if Ruff actually falls back to the bundled version but it does seem that it simply ignores the configuration in that case, which gives you the undesired result. I worry, that it's slightly difficult to catch the version mismatch error in the server code only or, it may require some refactors to propagate the error code all the way back to the server. |
What's not entirely clear to me is what the expected behavior is. Is it that ruff emits an error but keeps linting/formatting or that ruff emits an error and the linter and formatter are turned off? |
I would say the issue consists of 2 parts:
|
This will require parsing the
I think you're correct that the linked issue will solve your use-case here but only partially. This is because the extension will throw an error as there was no I'm a bit hesitant to add logic to consider the |
pyproject.toml
config when required-version
does not matchrequired-version
when finding the ruff
binary
(I don't consider this as bug but a feature request as I think it's currently working as intended) |
@dhruvmanila I would argue this ticket is a bug, as the required-version documentation states:
And the usage is broken when using ruff-vscode, as it falls back to the bundled executable of the ruff binary. Also possibly using an entirely different ruff configuration, as it doesn't honor the other rules defined next to the |
I think there's a misunderstanding of what
Yes, but that's because the behavior is expected at the extension level. What happens is that the extension tries to find the Writing that out explicitly made me think that the fix should be at the server level where we should handle this specific error explicitly by:
|
(My previous comment is mostly me thinking out loud :)) |
Context
At our company, we configure the
required-version
to a specific allowed version inpyproject.toml
like this:Issue
If you don't have ruff, or a different version installed, you get the following error notification:
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
With correct ruff version installed
uv venv --python=312
source .venv/bin/activate
uv pip install ruff==0.9.3
>Ruff: format document
Result: no change, expected behaviour
Without ruff installed (or incorrect version)
>Ruff: format document
Result: code reformatted, ignoring
line-length = 150
defined bypyproject.toml
Question
The text was updated successfully, but these errors were encountered: