Skip to content
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

Avoid deprecation warning if client is VS Code #522

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Feb 9, 2025

Summary

Related: astral-sh/ruff-vscode#685

This PR removes the deprecation warning for VS Code client and removes the version check as well as it's not needed for other editors.

Test Plan

While testing astral-sh/ruff-vscode#685 with local ruff-lsp on this branch, VS Code should only provides notification from the extension and not the one from ruff-lsp.

@dhruvmanila dhruvmanila marked this pull request as ready for review February 10, 2025 05:58
ruff_lsp/server.py Outdated Show resolved Hide resolved
@dhruvmanila dhruvmanila merged commit 304c1e6 into main Feb 10, 2025
20 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/no-deprecation-warning-for-vs-code branch February 10, 2025 09:23
dhruvmanila added a commit to astral-sh/ruff-vscode that referenced this pull request Feb 10, 2025
## Summary

Related: astral-sh/ruff-lsp#522

## Test Plan

### 1. User explicitly sets native server "on" with legacy settings

`settings.json`:
```json
{
	"ruff.nativeServer": "on",
	"ruff.lint.args": []
}
```

Logs:
```
2025-02-10 10:47:34.157 [warning] Following settings have been deprecated in the native server: ["ruff.lint.args"]. Please [migrate](https://docs.astral.sh/ruff/editors/migration/) to the new settings or remove them. Feel free to comment on the [GitHub discussion](astral-sh/ruff#15991) to ask questions or share feedback.
```

Notification:

<img width="493" alt="Screenshot 2025-02-10 at 10 47 44 AM"
src="https://github.com/user-attachments/assets/9571e7f6-ae15-4ca8-b59f-6b98d5f7a78e"
/>

### 2. User explicitly sets native server "off" with no legacy settings

`settings.json`:
```json
{
	"ruff.nativeServer": "off"
}
```

Logs:
```
2025-02-10 10:49:26.272 [warning] Legacy server ([ruff-lsp](https://github.com/astral-sh/ruff-lsp)) has been deprecated. Please consider using the native server instead by removing 'ruff.nativeServer' or setting it to 'on'. Feel free to comment on the [GitHub discussion](astral-sh/ruff#15991) to ask questions or share feedback.
```

Notification:

<img width="474" alt="Screenshot 2025-02-10 at 10 49 30 AM"
src="https://github.com/user-attachments/assets/bc4b2162-dcdc-4ad2-9c99-9e67b7caa07d"
/>

### 3. User explicitly sets native server "off" with legacy settings

`settings.json`:
```json
{
	"ruff.nativeServer": "off",
	"ruff.lint.args": []
}
```

Logs:
```
2025-02-10 10:50:44.897 [warning] Legacy server ([ruff-lsp](https://github.com/astral-sh/ruff-lsp)) has been deprecated. Please consider using the native server instead by removing 'ruff.nativeServer' or setting it to 'on'. Following settings are not supported with the native server and have been deprecated: ["ruff.lint.args"]. Please [migrate](https://docs.astral.sh/ruff/editors/migration/) to the new settings or remove them. Feel free to comment on the [GitHub discussion](astral-sh/ruff#15991) to ask questions or share feedback.
```

Notification:
<img width="481" alt="Screenshot 2025-02-10 at 10 50 53 AM"
src="https://github.com/user-attachments/assets/acce505d-66fb-4b7b-8e1c-e27a92b419e1"
/>

### 4. Auto behavior with legacy settings

`settings.json`:
```json
{
	"ruff.nativeServer": "auto",
	"ruff.lint.args": []
}
```

Logs:
```
2025-02-10 10:52:07.449 [warning] Legacy server ([ruff-lsp](https://github.com/astral-sh/ruff-lsp)) has been deprecated. Please consider using the native server instead by setting 'ruff.nativeServer' to 'on'. Following settings are not supported with the native server and have been deprecated: ["ruff.lint.args"]. Please [migrate](https://docs.astral.sh/ruff/editors/migration/) to the new settings or remove them. Feel free to comment on the [GitHub discussion](astral-sh/ruff#15991) to ask questions or share feedback.
```

Notification:
<img width="472" alt="Screenshot 2025-02-10 at 10 52 13 AM"
src="https://github.com/user-attachments/assets/dc98545d-85a4-460e-8b66-ad804fea2a0b"
/>

### 5. Auto behavior with non-stable `ruff server`

Same as (4) with Ruff 0.5.2 installed. The notification message is the
same except that the logs include an additional mesage:
```
2025-02-10 11:22:56.654 [info] Stable version of the native server requires Ruff 0.5.3, but found 0.5.2 at /Users/dhruv/.local/bin/ruff instead
2025-02-10 11:22:56.654 [warning] Legacy server ([ruff-lsp](https://github.com/astral-sh/ruff-lsp)) has been deprecated. Please consider using the native server instead by setting 'ruff.nativeServer' to 'on'. Following settings are not supported with the native server and have been deprecated: ["ruff.lint.args"]. Please [migrate](https://docs.astral.sh/ruff/editors/migration/) to the new settings or remove them. Feel free to comment on the [GitHub discussion](astral-sh/ruff#15991) to ask questions or share feedback.
```

### 6. Auto behavior with Ruff without the `server` command

This uses Ruff 0.3.4 and will first provide a warning message same as
(4) and when the user sets `nativeServer` to `on`, they'll get an error:

<img width="472" alt="Screenshot 2025-02-10 at 11 25 51 AM"
src="https://github.com/user-attachments/assets/2217f71f-5458-4bd6-8bfe-f9b2dba28cc8"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants