From 9d91e87190f8bbda78d0b92c974e2e309eb992bd Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Mon, 9 Feb 2026 02:24:49 +0530 Subject: [PATCH] refactor: remove unnecessary type casting in CRUD operations for delete and update methods --- backend/app/db/crud.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app/db/crud.py b/backend/app/db/crud.py index d5689c7a..bd61f6bc 100644 --- a/backend/app/db/crud.py +++ b/backend/app/db/crud.py @@ -1,7 +1,7 @@ from __future__ import annotations from collections.abc import Iterable, Mapping -from typing import Any, TypeVar, cast +from typing import Any, TypeVar from sqlalchemy import delete as sql_delete from sqlalchemy import update as sql_update @@ -154,10 +154,10 @@ async def delete_where( *criteria: Any, commit: bool = False, ) -> int: - stmt = sql_delete(model) + stmt: Any = sql_delete(model) if criteria: stmt = stmt.where(*criteria) - result = await session.exec(cast(Any, stmt)) + result = await session.exec(stmt) if commit: await _commit_or_rollback(session) rowcount = getattr(result, "rowcount", None) @@ -190,10 +190,10 @@ async def update_where( if not values: return 0 - stmt = sql_update(model).values(**values) + stmt: Any = sql_update(model).values(**values) if criteria: stmt = stmt.where(*criteria) - result = await session.exec(cast(Any, stmt)) + result = await session.exec(stmt) if commit: await _commit_or_rollback(session) rowcount = getattr(result, "rowcount", None)