refactor: remove personal_rating, DRY get_or_404, fix ty errors
- Drop Product.personal_rating from model, API schemas, and all frontend views (list table, detail view, quick-edit form, new-product form) - Extract get_or_404 into backend/innercontext/api/utils.py; remove five duplicate copies from individual API modules - Fix all ty type errors: generic get_or_404 with TypeVar, cast() in coerce_effect_profile validator, col() for ilike on SQLModel column, dict[str, Any] annotation in test helper, ty: ignore for CORSMiddleware Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5e3c0c97e5
commit
6333c6678a
15 changed files with 30 additions and 81 deletions
|
|
@ -1,5 +1,5 @@
|
|||
from datetime import date, datetime
|
||||
from typing import ClassVar, Optional
|
||||
from typing import Any, ClassVar, Optional, cast
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from pydantic import field_validator, model_validator
|
||||
|
|
@ -160,7 +160,6 @@ class Product(SQLModel, table=True):
|
|||
is_tool: bool = Field(default=False)
|
||||
needle_length_mm: float | None = Field(default=None, gt=0)
|
||||
|
||||
personal_rating: int | None = Field(default=None, ge=1, le=10)
|
||||
personal_tolerance_notes: str | None = None
|
||||
personal_repurchase_intent: bool | None = None
|
||||
|
||||
|
|
@ -181,7 +180,7 @@ class Product(SQLModel, table=True):
|
|||
@classmethod
|
||||
def coerce_effect_profile(cls, v: object) -> object:
|
||||
if isinstance(v, dict):
|
||||
return ProductEffectProfile(**v)
|
||||
return ProductEffectProfile(**cast(dict[str, Any], v))
|
||||
return v
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
|
@ -324,8 +323,6 @@ class Product(SQLModel, table=True):
|
|||
if self.usage_notes:
|
||||
ctx["usage_notes"] = self.usage_notes
|
||||
|
||||
if self.personal_rating is not None:
|
||||
ctx["personal_rating"] = self.personal_rating
|
||||
if self.personal_tolerance_notes:
|
||||
ctx["personal_tolerance_notes"] = self.personal_tolerance_notes
|
||||
if self.personal_repurchase_intent is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue