refactor: replace try-except blocks with contextlib.suppress for cleaner error handling across multiple files

This commit is contained in:
Jack Lu
2026-05-01 19:30:11 +08:00
committed by Xubin Ren
parent 1c24f10236
commit d9800ecdd2
27 changed files with 98 additions and 195 deletions
@@ -12,25 +12,23 @@ Example:
import sys
import zipfile
from contextlib import suppress
from pathlib import Path
from quick_validate import validate_skill
def _is_within(path: Path, root: Path) -> bool:
try:
with suppress(ValueError):
path.relative_to(root)
return True
except ValueError:
return False
return False
def _cleanup_partial_archive(skill_filename: Path) -> None:
try:
if skill_filename.exists():
if skill_filename.exists():
with suppress(OSError):
skill_filename.unlink()
except OSError:
pass
def package_skill(skill_path, output_dir=None):