Skip to content

Commit

Permalink
Support red_knot binary for server (#572)
Browse files Browse the repository at this point in the history
## Summary

This PR provides minimal support for the `red_knot` binary to run the
server without performing any version checks.

## Test Plan

I've been using this branch for my testing of
astral-sh/ruff#12624
  • Loading branch information
dhruvmanila authored Aug 6, 2024
1 parent 3147b28 commit 30afd91
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,21 @@ async function createNativeServer(

traceInfo(`Found Ruff ${versionToString(ruffVersion)} at ${ruffBinaryPath}`);

if (!supportsNativeServer(ruffVersion)) {
const message = `Native server requires Ruff ${versionToString(
MINIMUM_NATIVE_SERVER_VERSION,
)}, but found ${versionToString(ruffVersion)} at ${ruffBinaryPath} instead`;
traceError(message);
vscode.window.showErrorMessage(message);
return Promise.reject();
if (!ruffBinaryPath.endsWith("red_knot")) {
if (!supportsNativeServer(ruffVersion)) {
const message = `Native server requires Ruff ${versionToString(
MINIMUM_NATIVE_SERVER_VERSION,
)}, but found ${versionToString(ruffVersion)} at ${ruffBinaryPath} instead`;
traceError(message);
vscode.window.showErrorMessage(message);
return Promise.reject();
}
}

let ruffServerArgs: string[];
if (supportsStableNativeServer(ruffVersion)) {
if (ruffBinaryPath.endsWith("red_knot")) {
ruffServerArgs = [RUFF_SERVER_SUBCOMMAND];
} else if (supportsStableNativeServer(ruffVersion)) {
ruffServerArgs = [RUFF_SERVER_SUBCOMMAND];
} else {
ruffServerArgs = [RUFF_SERVER_SUBCOMMAND, ...RUFF_SERVER_PREVIEW_ARGS];
Expand Down

0 comments on commit 30afd91

Please sign in to comment.