From 607f872c71f4b0e15278c8dc7ffb26d6569214d0 Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 22:14:48 +0100 Subject: [PATCH] fix pre-commit hook and code quality fixes --- .githooks/pre-commit | 34 ++++++++++++++++++++++++---------- backend/routes/booking.py | 3 ++- frontend/.prettierignore | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 06d88a0..5464890 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,12 +1,20 @@ #!/bin/bash -# Pre-commit hook to ensure generated types and constants are up-to-date +# Pre-commit hook to run code quality tools and ensure generated types are up-to-date set -e -echo "🔍 Checking shared constants..." -cd backend && uv run python validate_constants.py -cd .. +# Get the root of the repository +REPO_ROOT="$(git rev-parse --show-toplevel)" +cd "$REPO_ROOT" +echo "🔧 Running code quality checks (ruff, mypy, bandit, eslint, prettier)..." +echo "" + +# Run pre-commit framework hooks on staged files +cd backend && uv run pre-commit run +cd "$REPO_ROOT" + +echo "" echo "🔍 Checking if generated types are fresh..." # Check if api.ts is staged @@ -15,13 +23,19 @@ if git diff --cached --name-only | grep -q "frontend/app/generated/api.ts"; then else # Check if backend schema files have changed if git diff --cached --name-only | grep -qE "backend/(schemas|models|routes)"; then - echo "⚠️ Backend schema files changed but generated types not staged." - echo " Run 'make generate-types-standalone' and stage the changes." - echo "" - echo " To skip this check (not recommended): git commit --no-verify" - exit 1 + # Check if api.ts has unstaged changes (meaning types need to be staged) + if git diff --name-only | grep -q "frontend/app/generated/api.ts"; then + echo "⚠️ Backend schema files changed and generated types have unstaged changes." + echo " Run 'git add frontend/app/generated/api.ts' to stage the changes." + echo "" + echo " To skip this check (not recommended): git commit --no-verify" + exit 1 + else + echo "✓ Generated types are up to date (no changes needed)" + fi fi fi -echo "✅ Pre-commit checks passed" +echo "" +echo "✅ All pre-commit checks passed" diff --git a/backend/routes/booking.py b/backend/routes/booking.py index 6dddf96..b7cce58 100644 --- a/backend/routes/booking.py +++ b/backend/routes/booking.py @@ -1,5 +1,6 @@ """Booking routes for users to book appointments.""" +from collections.abc import Sequence from datetime import UTC, date, datetime, time, timedelta from fastapi import APIRouter, Depends, HTTPException, Query @@ -86,7 +87,7 @@ def _validate_booking_date(d: date) -> None: def _expand_availability_to_slots( - availability_slots: list[Availability], + availability_slots: Sequence[Availability], target_date: date, ) -> list[BookableSlot]: """Expand availability time ranges into 15-minute bookable slots.""" diff --git a/frontend/.prettierignore b/frontend/.prettierignore index 7898f26..e70a195 100644 --- a/frontend/.prettierignore +++ b/frontend/.prettierignore @@ -1,4 +1,5 @@ .next/ node_modules/ app/generated/ +test-results/