Use CWD to resolve settings from ruff.configuration
#14352
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a bug in the Ruff language server where the editor-specified configuration was resolved relative to the configuration directory and not the current working directory.
The existing behavior is confusing given that this config file is specified by the user and is not discovered by Ruff itself. The behavior of resolving this configuration file should be similar to that of the
--config
flag on the command-line which uses the current working directory:ruff/crates/ruff/src/resolve.rs
Lines 34 to 48 in 3210f1a
This creates problems where certain configuration options doesn't work because the paths resolved in that case are relative to the configuration directory and not the current working directory in which the editor is expected to be in. For example, the
lint.per-file-ignores
doesn't work as mentioned in the linked issue along withexclude
,extend-exclude
, etc.fixes: #14282
Test Plan
Using the following directory tree structure:
where, the
ruff.toml
is:And, the content of
a.py
:"""Test"""
And, the VS Code settings:
I also tested out just opening the file in single-file mode where the current working directory is
/
in VS Code. Here, theruff.configuration
needs to be updated to use absolute path as shown in the above VS Code settings.