Skip to content

Conversation

weilycoder
Copy link
Contributor

@weilycoder weilycoder commented Mar 8, 2025

{sys.executable} 相关代码实现路径转义,保证 shell 解析不会错误

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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_path to quote and normalize paths for different OS shells.
  • Updates __all__ and imports in utils.py.
  • Refactors tests in io_test.py and compare_test.py to use escape_path for sys.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_path is 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_path to validate its output on both Windows and POSIX platforms, ensuring both branches (os.name == 'nt' and the else case) are covered.
def escape_path(path: str) -> str:

@Mr-Python-in-China Mr-Python-in-China merged commit 7056a5a into luogu-dev:master Jun 30, 2025
2 checks passed
@weilycoder weilycoder deleted the fix1 branch June 30, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants