mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 14:25:08 +00:00
* ci: mypy ratchet -- keep type-clean modules clean mypy-clean.txt lists the 71 modules under src/ that type-check clean; scripts/check_types.py runs mypy (--follow-imports=silent) on exactly those files and fails on any error or a missing/unsorted/duplicate entry. A new "Type check (mypy ratchet)" CI job runs it with mypy 1.20.2 and pinned stubs; the manual pre-commit mypy hook now runs the same script (a local hook, so mypy sees the installed requirements like CI does). 35 modules were made clean with annotation-only fixes: hints, typing.cast, TYPE_CHECKING imports, implicit-Optional defaults made explicit, and annotations widened (never guards removed) where mypy called a defensive isinstance check unreachable. No runtime behaviour change. mypy.ini: numpy and orjson are treated as Any (follow_imports=skip, also for stubs). numpy 2.3+ stubs use 3.12 `type` statements that mypy won't parse at python_version 3.10, and orjson is optional, so seeing its stubs made the result depend on whether it was installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: annotate check_types.py's list-form mypy subprocess Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.3 KiB
YAML
73 lines
2.3 KiB
YAML
# Pre-commit hooks for LEDMatrix
|
|
# Install: pip install pre-commit && pre-commit install
|
|
# Run manually: pre-commit run --all-files
|
|
|
|
repos:
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.5.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
- id: end-of-file-fixer
|
|
- id: check-yaml
|
|
- id: check-json
|
|
- id: check-added-large-files
|
|
args: ['--maxkb=1000']
|
|
- id: check-merge-conflict
|
|
|
|
- repo: https://github.com/PyCQA/flake8
|
|
rev: 7.0.0
|
|
hooks:
|
|
- id: flake8
|
|
args: ['--select=E9,F63,F7,F82,B', '--ignore=E501']
|
|
additional_dependencies: [flake8-bugbear]
|
|
|
|
- repo: local
|
|
hooks:
|
|
- id: no-bare-except
|
|
name: Check for bare except clauses
|
|
entry: bash -c 'if grep -rn "except:\s*pass" src/; then echo "Found bare except:pass - please handle exceptions properly"; exit 1; fi'
|
|
language: system
|
|
types: [python]
|
|
pass_filenames: false
|
|
|
|
- id: no-hardcoded-paths
|
|
name: Check for hardcoded user paths
|
|
entry: bash -c 'if grep -rn "/home/chuck/" src/; then echo "Found hardcoded user paths - please use relative paths or config"; exit 1; fi'
|
|
language: system
|
|
types: [python]
|
|
pass_filenames: false
|
|
|
|
# The mypy ratchet -- the same check as CI's "Type check (mypy ratchet)"
|
|
# job: mypy on exactly the modules listed in mypy-clean.txt. Run it with
|
|
# pre-commit run mypy --hook-stage manual
|
|
# A local hook rather than mirrors-mypy so mypy sees the packages installed
|
|
# from requirements.txt, as CI does; an isolated hook env without them types
|
|
# PIL, requests and friends as Any and reports different errors. Needs
|
|
# mypy==1.20.2 (the version CI pins) in the environment you commit from.
|
|
- repo: local
|
|
hooks:
|
|
- id: mypy
|
|
name: mypy (ratchet, mypy-clean.txt)
|
|
entry: python scripts/check_types.py
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
stages: [manual]
|
|
|
|
- repo: https://github.com/PyCQA/bandit
|
|
rev: 1.8.3
|
|
hooks:
|
|
- id: bandit
|
|
args:
|
|
- '-r'
|
|
- '-ll'
|
|
- '-c'
|
|
- 'bandit.yaml'
|
|
- '-x'
|
|
- './tests,./test,./venv,./.venv,./scripts/prove_security.py,./rpi-rgb-led-matrix-master'
|
|
|
|
- repo: https://github.com/gitleaks/gitleaks
|
|
rev: v8.24.3
|
|
hooks:
|
|
- id: gitleaks
|