Fix: Ensure the path format is correct#175
Merged
Mr-Python-in-China merged 2 commits intoluogu-dev:masterfrom Jun 30, 2025
Merged
Fix: Ensure the path format is correct#175Mr-Python-in-China merged 2 commits intoluogu-dev:masterfrom
Mr-Python-in-China merged 2 commits intoluogu-dev:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ensures shell-safe formatting of executable paths by introducing a new utility and applying it to existing tests.
- Adds
escape_pathto quote and normalize paths for different OS shells. - Updates
__all__and imports inutils.py. - Refactors tests in
io_test.pyandcompare_test.pyto useescape_pathforsys.executable.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cyaron/utils.py | Define escape_path and include it in __all__ |
| cyaron/tests/io_test.py | Import escape_path and wrap sys.executable in test commands |
| cyaron/tests/compare_test.py | Import escape_path and update compare tests to use it |
Comments suppressed due to low confidence (2)
cyaron/utils.py:86
- The docstring for
escape_pathis very brief; consider expanding it to describe the platform-specific quoting behavior and include a short usage example.
"""Escape the path."""
cyaron/utils.py:85
- Add dedicated unit tests for
escape_pathto validate its output on both Windows and POSIX platforms, ensuring both branches (os.name == 'nt'and theelsecase) are covered.
def escape_path(path: str) -> str:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
将
{sys.executable}相关代码实现路径转义,保证 shell 解析不会错误