Skip to content

Commit

Permalink
Avoid deprecation warning if client is VS Code (#522)
Browse files Browse the repository at this point in the history
## 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`.
  • Loading branch information
dhruvmanila authored Feb 10, 2025
1 parent 83cbefe commit 304c1e6
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions ruff_lsp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,24 +1616,21 @@ def initialize(params: InitializeParams) -> None:

_update_workspace_settings(settings)

# Use the Ruff executable from the first workspace to determine when to show the
# deprecation warning.
executable = _find_ruff_binary(
next(iter(WORKSPACE_SETTINGS.values())), version_requirement=None
if os.getenv("LS_SHOW_DEPRECATION_WARNING") == "False":
# The extension is responsible for providing the deprecation warning.
return

show_warning(
"`ruff-lsp` is deprecated. Please switch to the native language server "
"(`ruff server`). Refer to the "
"[setup guide](https://docs.astral.sh/ruff/editors/setup/) on how to set "
"up the native language server and the "
"[migration guide](https://docs.astral.sh/ruff/editors/migration/) on how "
"to migrate the settings. Feel free to comment on the "
"[GitHub discussion](https://github.com/astral-sh/ruff/discussions/15991) "
"to ask questions or share feedback."
)

if VERSION_REQUIREMENT_NATIVE_SERVER.contains(executable.version, prereleases=True):
show_warning(
"`ruff-lsp` is deprecated. Please switch to the native language server "
"(`ruff server`). Refer to the "
"[setup guide](https://docs.astral.sh/ruff/editors/setup/) on how to set "
"up the native language server and the "
"[migration guide](https://docs.astral.sh/ruff/editors/migration/) on how "
"to migrate the settings. Feel free to comment on the "
"[GitHub discussion](https://github.com/astral-sh/ruff/discussions/15991) "
"to ask questions or share feedback."
)


def _supports_code_action_resolve(capabilities: ClientCapabilities) -> bool:
"""Returns True if the client supports codeAction/resolve request for edits."""
Expand Down

0 comments on commit 304c1e6

Please sign in to comment.