"""Fail if a shipped file contains non-ASCII bytes.""" import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent FILES = sorted([*ROOT.glob("*.py"), *ROOT.glob("tests/*.py"), ROOT / "Dockerfile"]) bad: list[str] = [] for path in FILES: if not path.exists(): continue for number, line in enumerate(path.read_bytes().splitlines(), 1): if any(byte > 0x7F for byte in line): bad.append(f"{path.relative_to(ROOT)}:{number}") print("\n".join(bad) if bad else "ascii ok") sys.exit(1 if bad else 0)