Fix: Issues flagged by mypy

This commit is contained in:
Amritanshu Agrawal 2024-12-17 09:47:25 +05:30
parent 85a939b761
commit 43a884144b
8 changed files with 21 additions and 12 deletions

View File

@ -104,13 +104,12 @@ def update_route(
def delete_route( def delete_route(
id_: uuid.UUID, id_: uuid.UUID,
user: UserToken = Security(get_user, scopes=["customers"]), user: UserToken = Security(get_user, scopes=["customers"]),
) -> schemas.GuestBookIn: ) -> None:
try: try:
with SessionFuture() as db: with SessionFuture() as db:
item: GuestBook = db.execute(select(GuestBook).where(GuestBook.id == id_)).scalar_one() item: GuestBook = db.execute(select(GuestBook).where(GuestBook.id == id_)).scalar_one()
db.delete(item) db.delete(item)
db.commit() db.commit()
return blank_guest_book_info()
except SQLAlchemyError as e: except SQLAlchemyError as e:
raise HTTPException( raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,

View File

@ -233,7 +233,6 @@ def modifier_category_info(item: ModifierCategory, date_: date, db: Session) ->
schemas.MenuCategoryLink( schemas.MenuCategoryLink(
id_=mc.id, id_=mc.id,
name=mc.name, name=mc.name,
enabled=False,
products=[ products=[
ProductLinkSchema( ProductLinkSchema(
id_=p.product_id, id_=p.product_id,
@ -284,7 +283,6 @@ def modifier_category_blank(date_: date, db: Session) -> schemas.ModifierCategor
schemas.MenuCategoryLink( schemas.MenuCategoryLink(
id_=mc.id, id_=mc.id,
name=mc.name, name=mc.name,
enabled=False,
products=[ProductLinkSchema(id_=p.product_id, name=p.name, enabled=False) for p in mc.products], products=[ProductLinkSchema(id_=p.product_id, name=p.name, enabled=False) for p in mc.products],
) )
for mc in menu_categories for mc in menu_categories

View File

@ -1,5 +1,7 @@
import uuid import uuid
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from . import Daf, to_camel from . import Daf, to_camel
@ -8,8 +10,8 @@ from . import Daf, to_camel
class CustomerDiscount(BaseModel): class CustomerDiscount(BaseModel):
id_: uuid.UUID id_: uuid.UUID
name: str name: str
discount: Daf = Field(ge=0, default=0, le=1) discount: Daf = Field(ge=Decimal(0), default=Decimal(0), le=Decimal(1))
limit: Daf = Field(ge=0, default=0, le=1) limit: Daf = Field(ge=Decimal(0), default=Decimal(0), le=Decimal(1))
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)

View File

@ -1,5 +1,8 @@
import uuid import uuid
from decimal import Decimal
from typing import Annotated
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from . import Daf, to_camel from . import Daf, to_camel
@ -8,7 +11,7 @@ from . import Daf, to_camel
class DiscountItem(BaseModel): class DiscountItem(BaseModel):
id_: uuid.UUID id_: uuid.UUID
name: str name: str
discount: Daf | None = Field(ge=0, default=0, le=1) discount: Annotated[Daf | None, Field(ge=Decimal(0), default=Decimal(0), le=Decimal(1))]
limit: Daf limit: Daf
customer: Daf customer: Daf
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)

View File

@ -1,5 +1,7 @@
import uuid import uuid
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from . import Daf, to_camel from . import Daf, to_camel
@ -9,7 +11,7 @@ from .modifier_category import ModifierCategoryLink
class ModifierIn(BaseModel): class ModifierIn(BaseModel):
name: str = Field(..., min_length=1) name: str = Field(..., min_length=1)
show_in_bill: bool show_in_bill: bool
price: Daf = Field(ge=0, default=0) price: Daf = Field(ge=Decimal(0), default=Decimal(0))
is_active: bool is_active: bool
modifier_category: ModifierCategoryLink modifier_category: ModifierCategoryLink
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)

View File

@ -1,6 +1,7 @@
import uuid import uuid
from datetime import date, datetime from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
@ -17,7 +18,7 @@ class ProductIn(BaseModel):
price: Daf # = Field(ge=0, default=0) price: Daf # = Field(ge=0, default=0)
has_happy_hour: bool has_happy_hour: bool
is_not_available: bool is_not_available: bool
quantity: Daf = Field(ge=0, default=0) quantity: Daf = Field(ge=Decimal(0), default=Decimal(0))
is_active: bool is_active: bool
sort_order: int sort_order: int
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)

View File

@ -1,5 +1,7 @@
import uuid import uuid
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from . import Daf, to_camel from . import Daf, to_camel
@ -8,7 +10,7 @@ from .tax import TaxLink
class SaleCategoryIn(BaseModel): class SaleCategoryIn(BaseModel):
name: str = Field(..., min_length=1) name: str = Field(..., min_length=1)
discount_limit: Daf = Field(ge=0, default=0, le=1) discount_limit: Daf = Field(ge=Decimal(0), default=Decimal(0), le=Decimal(1))
tax: TaxLink = Field(...) tax: TaxLink = Field(...)
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)

View File

@ -1,5 +1,7 @@
import uuid import uuid
from decimal import Decimal
from pydantic import BaseModel, ConfigDict, Field from pydantic import BaseModel, ConfigDict, Field
from . import Daf, to_camel from . import Daf, to_camel
@ -8,7 +10,7 @@ from .regime import RegimeLink
class TaxIn(BaseModel): class TaxIn(BaseModel):
name: str = Field(..., min_length=1) name: str = Field(..., min_length=1)
rate: Daf = Field(ge=0, default=0) rate: Daf = Field(ge=Decimal(0), default=Decimal(0))
regime: RegimeLink = Field(...) regime: RegimeLink = Field(...)
is_fixture: bool is_fixture: bool
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)
@ -21,7 +23,7 @@ class Tax(TaxIn):
class TaxBlank(BaseModel): class TaxBlank(BaseModel):
name: str name: str
rate: Daf = Field(ge=0, default=0) rate: Daf = Field(ge=Decimal(0), default=Decimal(0))
is_fixture: bool is_fixture: bool
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True) model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel, populate_by_name=True)