formatting

This commit is contained in:
Ian Roddis committed 2026-09-21 14:16:17 -03:00
1 parent 4fd2bb1b58
commit 054770d370
2 files changed
+26 -16

No files matched your search

+2 -6
View File
@@ -12,9 +12,7 @@ class ManufacturerBase(BaseModel):
url: HttpUrl | None = None url: HttpUrl | None = None
logo_url: HttpUrl | None = None logo_url: HttpUrl | None = None
_normalize_url = field_validator("url", "logo_url", mode="before")( _normalize_url = field_validator("url", "logo_url", mode="before")(_blank_to_none)
_blank_to_none
)
class ManufacturerCreate(ManufacturerBase): class ManufacturerCreate(ManufacturerBase):
@@ -26,9 +24,7 @@ class ManufacturerUpdate(BaseModel):
url: HttpUrl | None = None url: HttpUrl | None = None
logo_url: HttpUrl | None = None logo_url: HttpUrl | None = None
_normalize_url = field_validator("url", "logo_url", mode="before")( _normalize_url = field_validator("url", "logo_url", mode="before")(_blank_to_none)
_blank_to_none
)
class ManufacturerRead(ManufacturerBase): class ManufacturerRead(ManufacturerBase):
+24 -10
View File
@@ -145,11 +145,15 @@ def parse_workbook(data: bytes) -> list[dict]:
wb.close() wb.close()
async def _static_ap(db: AsyncSession, *, augmented_part_id: int, label: str, od_mm: float): async def _static_ap(
db: AsyncSession, *, augmented_part_id: int, label: str, od_mm: float
):
"""Create an attachment point carrying a StaticConnection for ``od_mm``.""" """Create an attachment point carrying a StaticConnection for ``od_mm``."""
sc = await static_connection_crud.get_by_od_mm(db, od_mm) sc = await static_connection_crud.get_by_od_mm(db, od_mm)
if sc is None: if sc is None:
sc = await static_connection_crud.create(db, od_mm=od_mm, od_in=od_mm / MM_PER_INCH) sc = await static_connection_crud.create(
db, od_mm=od_mm, od_in=od_mm / MM_PER_INCH
)
apn = await apn_crud.get_by_name(db, label) apn = await apn_crud.get_by_name(db, label)
if apn is None: if apn is None:
apn = await apn_crud.create(db, name=label) apn = await apn_crud.create(db, name=label)
@@ -161,7 +165,9 @@ async def _static_ap(db: AsyncSession, *, augmented_part_id: int, label: str, od
) )
async def _thread_ap(db: AsyncSession, *, augmented_part_id: int, label: str, spec: str): async def _thread_ap(
db: AsyncSession, *, augmented_part_id: int, label: str, spec: str
):
"""Create an attachment point for a parsed ISO/UNC thread, or None.""" """Create an attachment point for a parsed ISO/UNC thread, or None."""
parsed = _parse_thread_attribute(spec) parsed = _parse_thread_attribute(spec)
if parsed is None: if parsed is None:
@@ -268,14 +274,18 @@ async def _link_fit(
if target_aps: if target_aps:
target_ap = target_aps[0] target_ap = target_aps[0]
else: else:
target_ap = await _mirrored_ap(db, augmented_part_id=target.id, scope_ap=scope_ap) target_ap = await _mirrored_ap(
db, augmented_part_id=target.id, scope_ap=scope_ap
)
messages.append( messages.append(
f"{scope_role}_fit '{target_sku}': referenced part had no attachment points, " f"{scope_role}_fit '{target_sku}': referenced part had no attachment points, "
"created one matching the scope's attachment point" "created one matching the scope's attachment point"
) )
existing = await fit_crud.get_by_attachment_points(db, scope_ap, target_ap) existing = await fit_crud.get_by_attachment_points(db, scope_ap, target_ap)
if existing is None: if existing is None:
await fit_crud.create(db, ap_a=scope_ap, ap_b=target_ap, label=FitLabel.POSSIBLE) await fit_crud.create(
db, ap_a=scope_ap, ap_b=target_ap, label=FitLabel.POSSIBLE
)
async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult: async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult:
@@ -300,9 +310,9 @@ async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult
model = _text(row.get("model")) model = _text(row.get("model"))
magnification_min = _num(row.get("magnification_min")) magnification_min = _num(row.get("magnification_min"))
magnification_max = _num(row.get("magnification_max")) magnification_max = _num(row.get("magnification_max"))
objective_lens_diameter_mm = _num(row.get("objective_lens_diameter_mm")) or _num( objective_lens_diameter_mm = _num(
row.get("objective_lens") row.get("objective_lens_diameter_mm")
) ) or _num(row.get("objective_lens"))
# Construct the model number # Construct the model number
default_product_number = model default_product_number = model
@@ -333,7 +343,9 @@ async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult
manufacturer = await manufacturer_crud.get_by_name(db, manufacturer_name) manufacturer = await manufacturer_crud.get_by_name(db, manufacturer_name)
if manufacturer is None: if manufacturer is None:
manufacturer = await manufacturer_crud.create(db, name=manufacturer_name, url="") manufacturer = await manufacturer_crud.create(
db, name=manufacturer_name, url=""
)
model_name = _text(row.get("model")) model_name = _text(row.get("model"))
url = _text(row.get("url")) url = _text(row.get("url"))
@@ -395,7 +407,9 @@ async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult
# Rebuild attachment points from scratch so re-imports stay idempotent # Rebuild attachment points from scratch so re-imports stay idempotent
# (cascades delete any fits that referenced the old points). # (cascades delete any fits that referenced the old points).
for old_ap in await attachment_point_crud.list_for_augmented_part(db, part.id): for old_ap in await attachment_point_crud.list_for_augmented_part(
db, part.id
):
await attachment_point_crud.delete(db, old_ap) await attachment_point_crud.delete(db, old_ap)
ocular_ap = None ocular_ap = None