-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
ruff server
: Introduce settings for directly configuring the linter and formatter
#10984
Merged
+222
−29
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
snowsignal
commented
Apr 16, 2024
MichaReiser
approved these changes
Apr 17, 2024
MichaReiser
reviewed
Apr 17, 2024
dhruvmanila
approved these changes
Apr 17, 2024
Loading status checks…
Will |
@charliermarsh That will come later! I'll be working on that next week. |
This was referenced Apr 21, 2024
snowsignal
added a commit
that referenced
this pull request
Apr 23, 2024
Loading
Loading status checks…
…ect configuration (#11062) ## Summary This is a follow-up to #10984 that implements configuration resolution for editor configuration. By 'editor configuration', I'm referring to the client settings that correspond to Ruff configuration/options, like `preview`, `select`, and so on. These will be combined with 'project configuration' (configuration taken from project files such as `pyproject.toml`) to generate the final linter and formatter settings used by `RuffSettings`. Editor configuration takes priority over project configuration. In a follow-up pull request, I'll implement a new client setting that allows project configuration to override editor configuration, as per [this issue](astral-sh/ruff-vscode#425). ## Review guide The first commit, e38966d, is just doing re-arrangement so that we can pass the right things to `RuffSettings::resolve`. The actual resolution logic is in the second commit, 0eec9ee. It might help to look at these comments individually since the diff is rather messy. ## Test Plan For the settings to show up in VS Code, you'll need to checkout this branch: astral-sh/ruff-vscode#456. To test that the resolution for a specific setting works as expected, run through the following scenarios, setting it in project and editor configuration as needed: | Set in project configuration? | Set in editor configuration? | Expected Outcome | |-------------------------------|--------------------------------------------------|------------------------------------------------------------------------------------------| | No | No | The editor should behave as if the setting was set to its default value. | | Yes | No | The editor should behave as if the setting was set to the value in project configuration. | | No | Yes | The editor should behave as if the setting was set to the value in editor configuration. | | Yes | Yes (but distinctive from project configuration) | The editor should behave as if the setting was set to the value in editor configuration. | An exception to this is `extendSelect`, which does not have an analog in TOML configuration. Instead, you should verify that `extendSelect` amends the `select` setting. If `select` is set in both editor and project configuration, `extendSelect` will only append to the `select` value in editor configuration, so make sure to un-set it there if you're testing `extendSelect` with `select` in project configuration.
snowsignal
added a commit
to astral-sh/ruff-vscode
that referenced
this pull request
Apr 25, 2024
## Summary This is a follow-up to astral-sh/ruff#10984, which implemented support for common Ruff configuration options in client settings. This PR exposes these new settings in the extension configuration. These settings are different from other extension settings, because they don't have default values. Instead, if the user does not set them, they will be sent as `null`, and the server will use project configuration instead. At the moment, `ruff server` does not actually resolve these settings yet - settings resolution is introduced in astral-sh/ruff#11062, which means that you'll need to work from that branch to test this PR (and vice-versa). ## Test Plan See the test plan in astral-sh/ruff#11062.
snowsignal
added a commit
to astral-sh/ruff-vscode
that referenced
this pull request
May 13, 2024
## Summary This is a follow-up to astral-sh/ruff#10984, which implemented support for common Ruff configuration options in client settings. This PR exposes these new settings in the extension configuration. These settings are different from other extension settings, because they don't have default values. Instead, if the user does not set them, they will be sent as `null`, and the server will use project configuration instead. At the moment, `ruff server` does not actually resolve these settings yet - settings resolution is introduced in astral-sh/ruff#11062, which means that you'll need to work from that branch to test this PR (and vice-versa). ## Test Plan See the test plan in astral-sh/ruff#11062.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The following client settings have been introduced to the language server:
lint.preview
format.preview
lint.select
lint.extendSelect
lint.ignore
exclude
lineLength
exclude
andlineLength
apply to both the linter and formatter.This does not actually use the settings yet, but makes them available for future use.
Test Plan
Snapshot tests have been updated.