Add YAPF style + ignore, and format tracked Python files

This commit is contained in:
2025-12-29 18:42:02 -08:00
parent c019c00aed
commit 507946a3e4
108 changed files with 11664 additions and 6494 deletions

26
scripts/format_tracked.py Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Format all tracked Python files using the repo's YAPF style.
This script intentionally formats only files tracked by git to avoid touching
files that are ignored (e.g., venv, site-packages).
"""
import subprocess
import sys
try:
out = subprocess.check_output(["git", "ls-files", "*.py"]).decode("utf-8")
except subprocess.CalledProcessError as exc:
print("Failed to get tracked files from git:", exc, file=sys.stderr)
sys.exit(1)
files = [f for f in (line.strip() for line in out.splitlines()) if f]
print(f"Formatting {len(files)} tracked python files...")
if not files:
print("No tracked python files found.")
sys.exit(0)
for path in files:
print(path)
subprocess.run([sys.executable, "-m", "yapf", "-i", "--style", ".style.yapf", path], check=False)
print("Done")