| 42 | |
| 43 | |
| 44 | def run_ruff(paths: Iterable[str]) -> list[dict]: |
| 45 | cmd = [sys.executable, "-m", "ruff", "check", *paths, "--output-format=json", "--exit-zero"] |
| 46 | proc = subprocess.run(cmd, capture_output=True, text=True) |
| 47 | if proc.returncode not in (0, 1): |
| 48 | print(proc.stdout) |
| 49 | print(proc.stderr, file=sys.stderr) |
| 50 | raise SystemExit(f"Failed to run Ruff: {' '.join(cmd)}") |
| 51 | data = json.loads(proc.stdout or "[]") |
| 52 | if not isinstance(data, list): |
| 53 | raise SystemExit("Unexpected Ruff JSON output") |
| 54 | return data |
| 55 | |
| 56 | |
| 57 | def relpath(path: str) -> str: |