mirror of
https://github.com/kuhyx/screen-locker.git
synced 2026-11-23 21:16:18 +01:00
Fix ruff findings in selector
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWZB8QEaFVQoa8CjuAw
This commit is contained in:
parent
55d5d29fed
commit
01b7a4a83f
@ -17,9 +17,12 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
_HEAD_ARG = 2
|
||||||
|
_GIT = shutil.which("git") or "git"
|
||||||
_LOG = logging.getLogger(__name__)
|
_LOG = logging.getLogger(__name__)
|
||||||
APP = "stronglift_replacement/workout_app"
|
APP = "stronglift_replacement/workout_app"
|
||||||
_DIRECTIVE = re.compile(r"^\s*(?:import|export|part)\s[^;]*;", re.MULTILINE)
|
_DIRECTIVE = re.compile(r"^\s*(?:import|export|part)\s[^;]*;", re.MULTILINE)
|
||||||
@ -141,7 +144,7 @@ def select(root: Path, changed: list[str], tracked: list[str]) -> Selection:
|
|||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
sel.why.append(
|
sel.why.append(
|
||||||
f"{len(sel.dart)} Dart tests reach {len(app_changed)} changed app files{extra}"
|
f"{len(sel.dart)} Dart tests reach {len(app_changed)} changed files{extra}"
|
||||||
)
|
)
|
||||||
sel.python, sel.full_python = python_tests_for(changed, tracked)
|
sel.python, sel.full_python = python_tests_for(changed, tracked)
|
||||||
if sel.full_python:
|
if sel.full_python:
|
||||||
@ -158,7 +161,7 @@ def select(root: Path, changed: list[str], tracked: list[str]) -> Selection:
|
|||||||
|
|
||||||
def _git(root: Path, *args: str) -> list[str]:
|
def _git(root: Path, *args: str) -> list[str]:
|
||||||
out = subprocess.run(
|
out = subprocess.run(
|
||||||
["git", *args], cwd=root, check=True, capture_output=True, text=True
|
[_GIT, *args], cwd=root, check=True, capture_output=True, text=True
|
||||||
).stdout
|
).stdout
|
||||||
return [line for line in out.splitlines() if line]
|
return [line for line in out.splitlines() if line]
|
||||||
|
|
||||||
@ -167,7 +170,7 @@ def main(argv: list[str]) -> int:
|
|||||||
"""Print the selection for BASE..HEAD as JSON."""
|
"""Print the selection for BASE..HEAD as JSON."""
|
||||||
root = Path(_git(Path.cwd(), "rev-parse", "--show-toplevel")[0])
|
root = Path(_git(Path.cwd(), "rev-parse", "--show-toplevel")[0])
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
base, head = argv[1], (argv[2] if len(argv) > 2 else "HEAD")
|
base, head = argv[1], (argv[_HEAD_ARG] if len(argv) > _HEAD_ARG else "HEAD")
|
||||||
changed = _git(root, "diff", "--name-only", f"{base}..{head}")
|
changed = _git(root, "diff", "--name-only", f"{base}..{head}")
|
||||||
sel = select(root, changed, _git(root, "ls-files", "*.py"))
|
sel = select(root, changed, _git(root, "ls-files", "*.py"))
|
||||||
sys.stdout.write(json.dumps(asdict(sel), indent=1) + "\n")
|
sys.stdout.write(json.dumps(asdict(sel), indent=1) + "\n")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user