👷 Run mypy by pre-commit (#2169)

This commit is contained in:
Motov Yurii
2026-02-03 21:28:50 +03:00
committed by GitHub
parent 7af1d80593
commit 8b35efe999
4 changed files with 15 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import uuid
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)
)

View File

@@ -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")