diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc718ea90d..9f19448ef5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,6 +40,13 @@ repos: language: unsupported types: [python] + - id: local-mypy + name: mypy check + entry: uv run mypy backend/app + require_serial: true + language: unsupported + pass_filenames: false + - id: generate-frontend-sdk name: Generate Frontend SDK entry: bash ./scripts/generate-client.sh diff --git a/backend/app/alembic/env.py b/backend/app/alembic/env.py index 7f29c04680..5e2c22f844 100755 --- a/backend/app/alembic/env.py +++ b/backend/app/alembic/env.py @@ -10,6 +10,7 @@ # Interpret the config file for Python logging. # This line sets up loggers basically. +assert config.config_file_name is not None fileConfig(config.config_file_name) # add your model's MetaData object here diff --git a/backend/app/api/routes/items.py b/backend/app/api/routes/items.py index 2b2ce57772..f1929e5836 100644 --- a/backend/app/api/routes/items.py +++ b/backend/app/api/routes/items.py @@ -2,7 +2,7 @@ from typing import Any from fastapi import APIRouter, HTTPException -from sqlmodel import func, select +from sqlmodel import col, func, select from app.api.deps import CurrentUser, SessionDep from app.models import Item, ItemCreate, ItemPublic, ItemsPublic, ItemUpdate, Message @@ -22,7 +22,7 @@ def read_items( count_statement = select(func.count()).select_from(Item) count = session.exec(count_statement).one() statement = ( - select(Item).order_by(Item.created_at.desc()).offset(skip).limit(limit) + select(Item).order_by(col(Item.created_at).desc()).offset(skip).limit(limit) ) items = session.exec(statement).all() else: @@ -35,7 +35,7 @@ def read_items( statement = ( select(Item) .where(Item.owner_id == current_user.id) - .order_by(Item.created_at.desc()) + .order_by(col(Item.created_at).desc()) .offset(skip) .limit(limit) ) diff --git a/backend/app/api/routes/users.py b/backend/app/api/routes/users.py index 61727949c8..35f64b626e 100644 --- a/backend/app/api/routes/users.py +++ b/backend/app/api/routes/users.py @@ -42,7 +42,9 @@ def read_users(session: SessionDep, skip: int = 0, limit: int = 100) -> Any: count_statement = select(func.count()).select_from(User) count = session.exec(count_statement).one() - statement = select(User).order_by(User.created_at.desc()).offset(skip).limit(limit) + statement = ( + select(User).order_by(col(User.created_at).desc()).offset(skip).limit(limit) + ) users = session.exec(statement).all() return UsersPublic(data=users, count=count) @@ -223,7 +225,7 @@ def delete_user( status_code=403, detail="Super users are not allowed to delete themselves" ) statement = delete(Item).where(col(Item.owner_id) == user_id) - session.exec(statement) # type: ignore + session.exec(statement) session.delete(user) session.commit() return Message(message="User deleted successfully")