mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-07-04 15:03:13 +02:00
Rewrites python_pkg.diet_guard imports to diet_guard, vendors the shared as_float coercion helper, drops the monorepo PYTHONPATH from install.sh and the systemd unit (package is now pip-installed), and scaffolds standalone lint/test config matching testsAndMisc's real enforced bar (pylint --fail-under=10 with tests excluded and the use-implicit-booleaness/consider-using-with disables, mypy's actual disabled-error-code set, ruff ALL, bandit, 100% branch coverage).
27 lines
622 B
Python
Executable File
27 lines
622 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Pre-commit hook: fail if any file exceeds MAX_LINES lines."""
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
MAX_LINES = 500
|
|
|
|
|
|
def main() -> int:
|
|
"""Return 1 if any file exceeds the line limit, else 0."""
|
|
failed = False
|
|
for filepath in sys.argv[1:]:
|
|
try:
|
|
with Path(filepath).open(encoding="utf-8", errors="replace") as fh:
|
|
count = sum(1 for _ in fh)
|
|
except OSError:
|
|
failed = True
|
|
continue
|
|
if count > MAX_LINES:
|
|
failed = True
|
|
return 1 if failed else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|