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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading