fix pre-commit hook and code quality fixes

This commit is contained in:
counterweight 2025-12-21 22:14:48 +01:00
parent d2fc802ef9
commit 607f872c71
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 27 additions and 11 deletions

View file

@ -1,12 +1,20 @@
#!/bin/bash #!/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 set -e
echo "🔍 Checking shared constants..." # Get the root of the repository
cd backend && uv run python validate_constants.py REPO_ROOT="$(git rev-parse --show-toplevel)"
cd .. 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..." echo "🔍 Checking if generated types are fresh..."
# Check if api.ts is staged # 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 else
# Check if backend schema files have changed # Check if backend schema files have changed
if git diff --cached --name-only | grep -qE "backend/(schemas|models|routes)"; then if git diff --cached --name-only | grep -qE "backend/(schemas|models|routes)"; then
echo "⚠️ Backend schema files changed but generated types not staged." # Check if api.ts has unstaged changes (meaning types need to be staged)
echo " Run 'make generate-types-standalone' and stage the changes." if git diff --name-only | grep -q "frontend/app/generated/api.ts"; then
echo "" echo "⚠️ Backend schema files changed and generated types have unstaged changes."
echo " To skip this check (not recommended): git commit --no-verify" echo " Run 'git add frontend/app/generated/api.ts' to stage the changes."
exit 1 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
fi fi
echo "✅ Pre-commit checks passed" echo ""
echo "✅ All pre-commit checks passed"

View file

@ -1,5 +1,6 @@
"""Booking routes for users to book appointments.""" """Booking routes for users to book appointments."""
from collections.abc import Sequence
from datetime import UTC, date, datetime, time, timedelta from datetime import UTC, date, datetime, time, timedelta
from fastapi import APIRouter, Depends, HTTPException, Query from fastapi import APIRouter, Depends, HTTPException, Query
@ -86,7 +87,7 @@ def _validate_booking_date(d: date) -> None:
def _expand_availability_to_slots( def _expand_availability_to_slots(
availability_slots: list[Availability], availability_slots: Sequence[Availability],
target_date: date, target_date: date,
) -> list[BookableSlot]: ) -> list[BookableSlot]:
"""Expand availability time ranges into 15-minute bookable slots.""" """Expand availability time ranges into 15-minute bookable slots."""

View file

@ -1,4 +1,5 @@
.next/ .next/
node_modules/ node_modules/
app/generated/ app/generated/
test-results/