Reformatting everything with black

This commit is contained in:
Ian Roddis committed 2026-07-14 14:36:49 -03:00
1 parent 7bd07f084a
commit 8185f1f8b3
48 files changed
+1000 -348

No files matched your search

+1 -3
View File
@@ -63,9 +63,7 @@ async def create(
return ap
async def update(
db: AsyncSession, ap: AttachmentPoint, data: dict
) -> AttachmentPoint:
async def update(db: AsyncSession, ap: AttachmentPoint, data: dict) -> AttachmentPoint:
for field, value in data.items():
setattr(ap, field, value)
await db.commit()
+12 -11
View File
@@ -48,7 +48,9 @@ async def list_filtered(
q = q.where(AugmentedPart.part_type_id == part_type_id)
if sub_part_type_id is not None:
q = q.where(AugmentedPart.sub_part_type_id == sub_part_type_id)
result = await db.execute(q.order_by(AugmentedPart.description).offset(skip).limit(limit))
result = await db.execute(
q.order_by(AugmentedPart.description).offset(skip).limit(limit)
)
return list(result.scalars().all())
@@ -62,6 +64,7 @@ async def count_filtered(
sub_part_type_id: int | None = None,
) -> int:
from sqlalchemy import func
q = select(func.count()).select_from(AugmentedPart)
if description.strip():
q = q.where(AugmentedPart.description.ilike(f"%{description.strip()}%"))
@@ -86,19 +89,18 @@ async def get_unlinked_imported_parts_filtered(
skip: int = 0,
limit: int = 50,
) -> list[ImportedPart]:
q = (
select(ImportedPart)
.where(
ImportedPart.InventoryID.not_in(
select(augmented_part_imported_parts.c.imported_part_id)
)
q = select(ImportedPart).where(
ImportedPart.InventoryID.not_in(
select(augmented_part_imported_parts.c.imported_part_id)
)
)
if description.strip():
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
if colour.strip():
q = q.where(ImportedPart.TBXColour.ilike(f"%{colour.strip()}%"))
result = await db.execute(q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit))
result = await db.execute(
q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit)
)
return list(result.scalars().all())
@@ -108,6 +110,7 @@ async def count_unlinked_filtered(
colour: str = "",
) -> int:
from sqlalchemy import func
q = (
select(func.count())
.select_from(ImportedPart)
@@ -166,9 +169,7 @@ async def create(
return ap
async def update(
db: AsyncSession, ap: AugmentedPart, data: dict
) -> AugmentedPart:
async def update(db: AsyncSession, ap: AugmentedPart, data: dict) -> AugmentedPart:
for field, value in data.items():
setattr(ap, field, value)
await db.commit()
+4 -4
View File
@@ -13,7 +13,9 @@ async def list_all(
) -> list[ClampConnection]:
result = await db.execute(
select(ClampConnection)
.order_by(ClampConnection.min_mm.nulls_last(), ClampConnection.min_in.nulls_last())
.order_by(
ClampConnection.min_mm.nulls_last(), ClampConnection.min_in.nulls_last()
)
.offset(skip)
.limit(limit)
)
@@ -35,9 +37,7 @@ async def create(
return cc
async def update(
db: AsyncSession, cc: ClampConnection, data: dict
) -> ClampConnection:
async def update(db: AsyncSession, cc: ClampConnection, data: dict) -> ClampConnection:
for field, value in data.items():
setattr(cc, field, value)
await db.commit()
+24 -8
View File
@@ -3,11 +3,18 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.models.imported_part import ImportedPart
_FIELDS = frozenset({
"InventoryID", "Description", "TBXColour",
"ProductMaxThreadDepthmm", "ProductMaxThreadDepthin",
"ProductODmm", "ProductODin", "TBXThreadAttribute",
})
_FIELDS = frozenset(
{
"InventoryID",
"Description",
"TBXColour",
"ProductMaxThreadDepthmm",
"ProductMaxThreadDepthin",
"ProductODmm",
"ProductODin",
"TBXThreadAttribute",
}
)
async def get(db: AsyncSession, inventory_id: str) -> ImportedPart | None:
@@ -18,7 +25,10 @@ async def list_all(
db: AsyncSession, skip: int = 0, limit: int = 500
) -> list[ImportedPart]:
result = await db.execute(
select(ImportedPart).order_by(ImportedPart.InventoryID).offset(skip).limit(limit)
select(ImportedPart)
.order_by(ImportedPart.InventoryID)
.offset(skip)
.limit(limit)
)
return list(result.scalars().all())
@@ -32,7 +42,9 @@ async def list_filtered(
q = select(ImportedPart)
if description.strip():
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
result = await db.execute(q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit))
result = await db.execute(
q.order_by(ImportedPart.InventoryID).offset(skip).limit(limit)
)
return list(result.scalars().all())
@@ -47,12 +59,14 @@ async def distinct_colours(db: AsyncSession) -> list[str]:
async def count(db: AsyncSession) -> int:
from sqlalchemy import func
result = await db.execute(select(func.count()).select_from(ImportedPart))
return result.scalar_one()
async def count_filtered(db: AsyncSession, description: str = "") -> int:
from sqlalchemy import func
q = select(func.count()).select_from(ImportedPart)
if description.strip():
q = q.where(ImportedPart.Description.ilike(f"%{description.strip()}%"))
@@ -81,7 +95,9 @@ async def upsert_bulk(db: AsyncSession, records: list[dict]) -> tuple[int, int]:
incoming_ids = {r["InventoryID"] for r in clean}
result = await db.execute(
select(ImportedPart.InventoryID).where(ImportedPart.InventoryID.in_(incoming_ids))
select(ImportedPart.InventoryID).where(
ImportedPart.InventoryID.in_(incoming_ids)
)
)
existing_ids = {row[0] for row in result.all()}
+6 -2
View File
@@ -16,7 +16,9 @@ async def get_by_values(
depth_mm: float | None,
) -> IsoThread | None:
depth_clause = (
IsoThread.depth_mm.is_(None) if depth_mm is None else IsoThread.depth_mm == depth_mm
IsoThread.depth_mm.is_(None)
if depth_mm is None
else IsoThread.depth_mm == depth_mm
)
result = await db.execute(
select(IsoThread).where(
@@ -28,7 +30,9 @@ async def get_by_values(
return result.scalar_one_or_none()
async def list_all(db: AsyncSession, skip: int = 0, limit: int = 100) -> list[IsoThread]:
async def list_all(
db: AsyncSession, skip: int = 0, limit: int = 100
) -> list[IsoThread]:
result = await db.execute(
select(IsoThread).order_by(IsoThread.id).offset(skip).limit(limit)
)
+1 -3
View File
@@ -9,9 +9,7 @@ async def get(db: AsyncSession, manufacturer_id: int) -> Manufacturer | None:
async def get_by_name(db: AsyncSession, name: str) -> Manufacturer | None:
result = await db.execute(
select(Manufacturer).where(Manufacturer.name == name)
)
result = await db.execute(select(Manufacturer).where(Manufacturer.name == name))
return result.scalar_one_or_none()
+1 -3
View File
@@ -9,9 +9,7 @@ async def get(db: AsyncSession, part_colour_id: int) -> PartColour | None:
async def get_by_name(db: AsyncSession, name: str) -> PartColour | None:
result = await db.execute(
select(PartColour).where(PartColour.name == name)
)
result = await db.execute(select(PartColour).where(PartColour.name == name))
return result.scalar_one_or_none()
+1 -3
View File
@@ -13,9 +13,7 @@ async def get_by_name(db: AsyncSession, name: str) -> PartType | None:
return result.scalar_one_or_none()
async def list_all(
db: AsyncSession, skip: int = 0, limit: int = 100
) -> list[PartType]:
async def list_all(db: AsyncSession, skip: int = 0, limit: int = 100) -> list[PartType]:
result = await db.execute(
select(PartType).order_by(PartType.name).offset(skip).limit(limit)
)
+4 -1
View File
@@ -19,7 +19,10 @@ async def list_all(
db: AsyncSession, skip: int = 0, limit: int = 100
) -> list[StaticConnection]:
result = await db.execute(
select(StaticConnection).order_by(StaticConnection.od_mm).offset(skip).limit(limit)
select(StaticConnection)
.order_by(StaticConnection.od_mm)
.offset(skip)
.limit(limit)
)
return list(result.scalars().all())
+1 -3
View File
@@ -28,9 +28,7 @@ async def list_all(
return list(result.scalars().all())
async def create(
db: AsyncSession, *, name: str, part_type_id: int
) -> SubPartType:
async def create(db: AsyncSession, *, name: str, part_type_id: int) -> SubPartType:
spt = SubPartType(name=name, part_type_id=part_type_id)
db.add(spt)
await db.commit()
+6 -2
View File
@@ -17,7 +17,9 @@ async def get_by_values(
depth_in: float | None,
) -> UncThread | None:
depth_clause = (
UncThread.depth_in.is_(None) if depth_in is None else UncThread.depth_in == depth_in
UncThread.depth_in.is_(None)
if depth_in is None
else UncThread.depth_in == depth_in
)
result = await db.execute(
select(UncThread).where(
@@ -30,7 +32,9 @@ async def get_by_values(
return result.scalar_one_or_none()
async def list_all(db: AsyncSession, skip: int = 0, limit: int = 100) -> list[UncThread]:
async def list_all(
db: AsyncSession, skip: int = 0, limit: int = 100
) -> list[UncThread]:
result = await db.execute(
select(UncThread).order_by(UncThread.id).offset(skip).limit(limit)
)