diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bec175de1..f99e61a8d6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,32 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_language_version: - python: python3.10 + python: python3 repos: + - repo: local + hooks: + - id: check-python-version + name: Ensure Python ≥ 3.10 + language: python + pass_filenames: false + always_run: true + entry: python + args: + - -c + - | + import sys + + required_major = 3 + required_minor = 10 + current_major, current_minor = sys.version_info[:2] + + if (current_major, current_minor) < (required_major, required_minor): + print( + f"ERROR: Python {current_major}.{current_minor} is too old " + f"(requires ≥ {required_major}.{required_minor})." + ) + raise SystemExit(1) - repo: local hooks: - id: check-env-file