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
  • Loading branch information
MichaReiser committed Aug 15, 2024
1 parent d84e14b commit bd76273
Showing 1 changed file with 8 additions and 1 deletion.
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 @@ -4,6 +4,13 @@
from pathlib import Path
from typing import Optional

# Python defaults to the system local encoding by default on Windows.
# source: https://docs.python.org/3/library/sys.html#sys.stdout
#
# This creates problems with unicode paths that aren't covered 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")

RUFF_EXE = "ruff.exe" if sys.platform == "win32" else "ruff"


Expand Down Expand Up @@ -32,4 +39,4 @@ def find_ruff_binary_path() -> Optional[Path]:
if __name__ == "__main__":
ruff_binary_path = find_ruff_binary_path()
if ruff_binary_path:
print(os.fsdecode(str(ruff_binary_path)), flush=True)
print(os.fsdecode(ruff_binary_path), flush=True)

0 comments on commit bd76273

Please sign in to comment.