Adjusted files for isort & autopep

This commit is contained in:
creyD
2025-04-04 15:55:18 +00:00
committed by github-actions[bot]
parent badf2b157f
commit 7afb8e2fd8
2 changed files with 4 additions and 5 deletions

View File

@@ -54,21 +54,20 @@ def get_object_or_404(
query = select(*selected_columns).where(getattr(db_class, lookup_column) == id) query = select(*selected_columns).where(getattr(db_class, lookup_column) == id)
result = await db.execute(query) result = await db.execute(query)
row = result.first() row = result.first()
if row is None: if row is None:
raise HTTPException(status_code=404, detail="The object does not exist.") raise HTTPException(status_code=404, detail="The object does not exist.")
if hasattr(row, "_mapping"): if hasattr(row, "_mapping"):
obj_dict = dict(row._mapping) obj_dict = dict(row._mapping)
else: else:
obj_dict = {column.key: getattr(row, column.key) obj_dict = {column.key: getattr(row, column.key) for column in selected_columns}
for column in selected_columns}
else: else:
query = select(db_class).where(getattr(db_class, lookup_column) == id) query = select(db_class).where(getattr(db_class, lookup_column) == id)
result = await db.execute(query) result = await db.execute(query)
row = result.scalar_one_or_none() row = result.scalar_one_or_none()
if row is None: if row is None:
raise HTTPException(status_code=404, detail="The object does not exist.") raise HTTPException(status_code=404, detail="The object does not exist.")
obj_dict = row obj_dict = row
if expunge: if expunge:
await db.expunge(obj_dict) await db.expunge(obj_dict)

View File

@@ -12,7 +12,7 @@ class ResponseModelDependency:
def process_result(result, fields=None, async_session=False): def process_result(result, fields=None, async_session=False):
if not fields: if not fields:
if async_session: if async_session:
return {k: v for k, v in result.__dict__.items() if not k.startswith('_')} return {k: v for k, v in result.__dict__.items() if not k.startswith("_")}
return result return result
if hasattr(result, "_fields"): if hasattr(result, "_fields"):