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 passing --preview flag for stable ruff server #535

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const FIND_RUFF_BINARY_SCRIPT_PATH = path.join(
export const RUFF_SERVER_SUBCOMMAND = "server";

/**
* Required arguments for the `ruff server` command.
* Arguments for the `ruff server` command required when it's under preview i.e.,
* not yet stabilized.
*/
export const RUFF_SERVER_REQUIRED_ARGS = ["--preview"];
export const RUFF_SERVER_PREVIEW_ARGS = ["--preview"];
9 changes: 7 additions & 2 deletions src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import {
BUNDLED_RUFF_EXECUTABLE,
DEBUG_SERVER_SCRIPT_PATH,
RUFF_SERVER_REQUIRED_ARGS,
RUFF_SERVER_PREVIEW_ARGS,
RUFF_SERVER_SUBCOMMAND,
RUFF_LSP_SERVER_SCRIPT_PATH,
FIND_RUFF_BINARY_SCRIPT_PATH,
Expand Down Expand Up @@ -176,7 +176,12 @@ async function createNativeServer(
return Promise.reject();
}

const ruffServerArgs = [RUFF_SERVER_SUBCOMMAND, ...RUFF_SERVER_REQUIRED_ARGS];
let ruffServerArgs: string[];
if (supportsStableNativeServer(ruffVersion)) {
ruffServerArgs = [RUFF_SERVER_SUBCOMMAND];
} else {
ruffServerArgs = [RUFF_SERVER_SUBCOMMAND, ...RUFF_SERVER_PREVIEW_ARGS];
}
traceInfo(`Server run command: ${[ruffBinaryPath, ...ruffServerArgs].join(" ")}`);

let serverOptions = {
Expand Down