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

Fix ruff discovery for paths containing symbols that can't be represented by the local encoding #584

Merged
merged 6 commits into from
Aug 16, 2024

Conversation

MichaReiser
Copy link
Member

Summary

Fixes #583

See inline comment for an explanation

Test Plan

  • Created a local directory named löカひ漢
  • Added a venv
  • installed ruff

Before fix: The python script crashed
After: It finds the right ruff binary

@MichaReiser MichaReiser added the bug Something isn't working label Aug 15, 2024
@@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the call to str before calling os.fsdecode is just wrong? But how would I know, I don't know nothing of Python

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's correct. print(<pathlib.Path>) would use the pathlib.Path.__str__ method, so the str call here is redundant.

@MichaReiser MichaReiser marked this pull request as ready for review August 15, 2024 18:02
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MichaReiser MichaReiser merged commit 8f0e0c3 into main Aug 16, 2024
6 checks passed
@MichaReiser MichaReiser deleted the fix-non-local-encoding-paths branch August 16, 2024 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension breaks on Windows if Ruff binary file path contains non-ASCII characters
2 participants