Skip to content

Commit

Permalink
Fix ruff discovery for paths containing symbols that can't be represe…
Browse files Browse the repository at this point in the history
…nted by the local encoding (#584)

Co-authored-by: Dhruv Manilawala <[email protected]>
  • Loading branch information
MichaReiser and dhruvmanila authored Aug 16, 2024
1 parent d84e14b commit 8f0e0c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion bundled/tool/find_ruff_binary_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def find_ruff_binary_path() -> Optional[Path]:


if __name__ == "__main__":
# Python defaults to the system's local encoding for stdout on Windows.
# source: https://docs.python.org/3/library/sys.html#sys.stdout
#
# But not all paths are representable by the local encoding.
# The node process calling this script defaults to UTF8, so let's do the same here.
sys.stdout.reconfigure(encoding="utf-8") # type: ignore [attr-defined] # We never reconfigure stdout, thus it is guaranteed to not be Any

ruff_binary_path = find_ruff_binary_path()
if ruff_binary_path:
print(os.fsdecode(str(ruff_binary_path)), flush=True)
print(ruff_binary_path, flush=True)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"scripts": {
"fmt": "prettier -w .",
"fmt-check": "prettier --check .",
"lint": "eslint src --ext ts",
"lint": "eslint src --ext ts --max-warnings=0",
"compile": "webpack",
"compile-tests": "tsc -p . --outDir out",
"tsc": "tsc --noEmit",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev = ["mypy==1.2.0", "python-lsp-jsonrpc==1.0.0"]
[tool.ruff]
line-length = 88
target-version = "py37"
extend-exclude = ["bundled/libs", "scr/testFixture"]
extend-exclude = ["bundled/libs", "src/testFixture"]

[tool.ruff.lint]
select = ["E", "F", "W", "Q", "UP", "I", "N"]
Expand Down
2 changes: 1 addition & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const EXTENSION_ROOT_DIR =
/**
* Name of the `ruff` binary based on the current platform.
*/
export const RUFF_BINARY_NAME = process.platform == "win32" ? "ruff.exe" : "ruff";
export const RUFF_BINARY_NAME = process.platform === "win32" ? "ruff.exe" : "ruff";

/**
* Path to the directory containing the bundled Python scripts.
Expand Down

0 comments on commit 8f0e0c3

Please sign in to comment.