File size: 654 Bytes
22b729d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from __future__ import annotations

from pathlib import Path

paths = [Path("services/api"), Path("workers"), Path("scripts"), Path("tests")]
violations: list[str] = []
for root in paths:
    for path in root.rglob("*.py"):
        text = path.read_text(encoding="utf-8")
        if "\t" in text:
            violations.append(f"{path}: contains tab")
        for i, line in enumerate(text.splitlines(), start=1):
            if line.rstrip() != line:
                violations.append(f"{path}:{i}: trailing whitespace")
if violations:
    raise SystemExit("Python style violations:\n" + "\n".join(violations[:50]))
print("Python style checks passed.")