diff --git a/barker/.pre-commit-config.yaml b/barker/.pre-commit-config.yaml index f94179f..379e5e8 100644 --- a/barker/.pre-commit-config.yaml +++ b/barker/.pre-commit-config.yaml @@ -2,25 +2,25 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 4.0.1 hooks: - id: flake8 args: ['--config=barker/.flake8'] - repo: https://github.com/timothycrosley/isort - rev: 5.6.2 + rev: 5.10.1 hooks: - id: isort additional_dependencies: [toml] exclude: ^.*/?setup\.py$ - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer diff --git a/barker/barker/core/security.py b/barker/barker/core/security.py index 6c3838a..7ea92c4 100644 --- a/barker/barker/core/security.py +++ b/barker/barker/core/security.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime, timedelta -from typing import List, Optional, Tuple from fastapi import Depends, HTTPException, Security, status from fastapi.security import OAuth2PasswordBearer, SecurityScopes @@ -30,7 +29,7 @@ class Token(BaseModel): class TokenData(BaseModel): username: str = "" - scopes: List[str] = [] + scopes: list[str] = [] def f7(seq): @@ -50,7 +49,7 @@ def create_access_token(*, data: dict, expires_delta: timedelta = None): return encoded_jwt -def get_user(username: str, id_: str, locked_out: bool, scopes: List[str]) -> UserToken: +def get_user(username: str, id_: str, locked_out: bool, scopes: list[str]) -> UserToken: return UserToken( id_=uuid.UUID(id_), name=username, @@ -60,12 +59,12 @@ def get_user(username: str, id_: str, locked_out: bool, scopes: List[str]) -> Us ) -def authenticate_user(username: str, password: str, db: Session) -> Optional[UserModel]: +def authenticate_user(username: str, password: str, db: Session) -> UserModel | None: user = UserModel.auth(username, password, db) return user -def device_allowed(user: UserModel, device_id: Optional[uuid.UUID], db: Session) -> Tuple[bool, Device]: +def device_allowed(user: UserModel, device_id: uuid.UUID | None, db: Session) -> tuple[bool, Device]: device: Device = db.execute(select(Device).where(Device.id == device_id)).scalars().one_or_none() if device is None: device = Device.create(db) diff --git a/barker/barker/printing/__init__.py b/barker/barker/printing/__init__.py index 2695716..58ba0ce 100644 --- a/barker/barker/printing/__init__.py +++ b/barker/barker/printing/__init__.py @@ -1,12 +1,11 @@ import locale from decimal import Decimal -from typing import Union -def currency_format(amount: Union[Decimal, int]) -> str: +def currency_format(amount: Decimal | int) -> str: return locale.currency(amount, symbol=False, grouping=True) -def format_no_decimals(amount: Union[Decimal, int]) -> str: +def format_no_decimals(amount: Decimal | int) -> str: return locale.format_string("%d", amount, grouping=True, monetary=True) diff --git a/barker/barker/printing/bill.py b/barker/barker/printing/bill.py index 6402245..cc21f2d 100644 --- a/barker/barker/printing/bill.py +++ b/barker/barker/printing/bill.py @@ -5,7 +5,6 @@ import uuid from datetime import timedelta from decimal import Decimal -from typing import List, Tuple from arq import ArqRedis, create_pool from barker.core.config import settings @@ -34,8 +33,8 @@ def print_bill(voucher_id: uuid.UUID, db: Session): .where(SectionPrinter.sale_category_id == None) # noqa: E711 ).scalar_one() - items_dict = {} - tax = {} + items_dict: dict[tuple[uuid.UUID, bool, Decimal, set[uuid.UUID]], Inventory] = {} + tax: dict[tuple[uuid.UUID, int], tuple[str, Decimal]] = {} for i in [i for k in voucher.kots for i in k.inventories]: key = ( i.product_id, @@ -62,7 +61,7 @@ def print_bill(voucher_id: uuid.UUID, db: Session): for i in [it for it in items_dict.values() if it.quantity != 0]: get_tax_item(i.tax.id, i.tax.name, i.tax_amount, tax) - data = design_bill(voucher, items_dict.values(), tax.values(), db) + data = design_bill(voucher, list(items_dict.values()), list(tax.values()), db) redis: ArqRedis = asyncio.run(create_pool(redis_settings)) asyncio.run( redis.enqueue_job( @@ -71,27 +70,29 @@ def print_bill(voucher_id: uuid.UUID, db: Session): ) -def get_tax_item(id_: uuid.UUID, tax_name: str, amount: Decimal, tax_dict: {}) -> None: +def get_tax_item( + id_: uuid.UUID, tax_name: str, amount: Decimal, tax_dict: dict[tuple[uuid.UUID, int], tuple[str, Decimal]] +) -> None: items = tax_name.split(";") if len(items) == 1: key = (id_, 0) - old_amount = tax_dict[key][1] if key in tax_dict else 0 + old_amount = tax_dict[key][1] if key in tax_dict else Decimal(0) tax_dict[key] = tax_name, round(amount + old_amount, 2) else: for i, item in enumerate(it.strip() for it in items): key = (id_, i) - old_amount = tax_dict[key][1] if key in tax_dict else 0 + old_amount = tax_dict[key][1] if key in tax_dict else Decimal(0) match = re.match(r"(^.*)\s+\((.*?)/(.*?)\)[^(]*$", item) if not match or len(match.groups()) != 3: raise Exception("Error in tax as it has multiple items, but the format is wrong.") - sub_amount = round(amount * Decimal(match.group(2)) / Decimal(match.group(3)), 2) + sub_amount: Decimal = round(amount * Decimal(match.group(2)) / Decimal(match.group(3)), 2) tax_dict[(id_, i)] = match.group(1), round(sub_amount + old_amount, 2) def design_bill( voucher: Voucher, - items: List[Tuple[Inventory, Decimal]], - tax: List[Tuple[str, Decimal]], + items: list[Inventory], + tax: list[tuple[str, Decimal]], db: Session, ): # Header diff --git a/barker/barker/printing/kot.py b/barker/barker/printing/kot.py index ef67025..7da8de9 100644 --- a/barker/barker/printing/kot.py +++ b/barker/barker/printing/kot.py @@ -2,7 +2,7 @@ import asyncio import uuid from datetime import timedelta -from typing import Any, Dict, List, Tuple +from typing import Any from arq import ArqRedis, create_pool from barker.core.config import settings @@ -18,7 +18,7 @@ from ..models.section_printer import SectionPrinter from ..models.voucher import Voucher -def design_kot(voucher: Voucher, kot: Kot, items: List[Inventory], copy_number: int, db: Session) -> str: +def design_kot(voucher: Voucher, kot: Kot, items: list[Inventory], copy_number: int, db: Session) -> str: date_ = kot.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES) product_date = ( voucher.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES) @@ -66,7 +66,7 @@ def design_kot(voucher: Voucher, kot: Kot, items: List[Inventory], copy_number: def print_kot(voucher_id: uuid.UUID, db: Session): voucher: Voucher = db.execute(select(Voucher).where(Voucher.id == voucher_id)).scalar_one() - my_hash: Dict[Tuple[uuid.UUID, int], Tuple[Printer, List[Any]]] = {} + my_hash: dict[tuple[uuid.UUID, int], tuple[Printer, list[Any]]] = {} kot: Kot = voucher.kots[-1] product_date = ( voucher.date + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES) diff --git a/barker/barker/routers/__init__.py b/barker/barker/routers/__init__.py index 39fd7ef..60824db 100644 --- a/barker/barker/routers/__init__.py +++ b/barker/barker/routers/__init__.py @@ -1,5 +1,4 @@ from datetime import date, datetime, timedelta -from typing import Optional from barker.core.config import settings @@ -8,7 +7,7 @@ def query_date(d: str = None) -> date: return date.today() if d is None else datetime.strptime(d, "%d-%b-%Y").date() -def optional_query_date(d: str = None) -> Optional[date]: +def optional_query_date(d: str = None) -> date | None: return None if d is None else datetime.strptime(d, "%d-%b-%Y").date() diff --git a/barker/barker/routers/customer.py b/barker/barker/routers/customer.py index 4b61584..3b39a86 100644 --- a/barker/barker/routers/customer.py +++ b/barker/barker/routers/customer.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.customer as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -31,7 +29,7 @@ def save( db.add(item) add_discounts(item, data.discounts, db) db.commit() - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() return customer_info(item, sc) except SQLAlchemyError as e: raise HTTPException( @@ -55,7 +53,7 @@ def update_route( item.print_in_bill = data.print_in_bill add_discounts(item, data.discounts, db) db.commit() - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() return customer_info(item, sc) except SQLAlchemyError as e: raise HTTPException( @@ -64,7 +62,7 @@ def update_route( ) -def add_discounts(customer: Customer, discounts: List[schemas.DiscountItem], db: Session) -> None: +def add_discounts(customer: Customer, discounts: list[schemas.DiscountItem], db: Session) -> None: for discount in discounts: cd = next((d for d in customer.discounts if d.sale_category_id == discount.id_), None) if cd is None: @@ -91,24 +89,24 @@ def show_blank( user: UserToken = Security(get_user, scopes=["customers"]), ) -> schemas.CustomerBlank: with SessionFuture() as db: - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() return blank_customer_info(sc) -@router.get("/list", response_model=List[schemas.Customer]) -def show_list(user: UserToken = Depends(get_user)) -> List[schemas.Customer]: +@router.get("/list", response_model=list[schemas.Customer]) +def show_list(user: UserToken = Depends(get_user)) -> list[schemas.Customer]: with SessionFuture() as db: - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() return [ customer_info(item, sc) for item in db.execute(select(Customer).order_by(Customer.name)).scalars().all() ] -@router.get("/query", response_model=List[schemas.Customer]) +@router.get("/query", response_model=list[schemas.Customer]) def show_term( q: str, current_user: UserToken = Depends(get_user), -) -> List[schemas.Customer]: +) -> list[schemas.Customer]: query = select(Customer) if q is not None: for item in q.split(): @@ -116,7 +114,7 @@ def show_term( query = query.order_by(Customer.name) with SessionFuture() as db: - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() return [customer_info(item, sc) for item in db.execute(query).scalars().all()] @@ -126,12 +124,12 @@ def show_id( user: UserToken = Security(get_user, scopes=["customers"]), ) -> schemas.Customer: with SessionFuture() as db: - sc: List[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() + sc: list[SaleCategory] = db.execute(select(SaleCategory).order_by(SaleCategory.name)).scalars().all() item: Customer = db.execute(select(Customer).where(Customer.id == id_)).scalar_one() return customer_info(item, sc) -def customer_info(item: Customer, sale_categories: List[SaleCategory]) -> schemas.Customer: +def customer_info(item: Customer, sale_categories: list[SaleCategory]) -> schemas.Customer: return schemas.Customer( id=item.id, name=item.name, @@ -149,7 +147,7 @@ def customer_info(item: Customer, sale_categories: List[SaleCategory]) -> schema ) -def blank_customer_info(sale_categories: List[SaleCategory]) -> schemas.CustomerBlank: +def blank_customer_info(sale_categories: list[SaleCategory]) -> schemas.CustomerBlank: return schemas.CustomerBlank( name="", address="", diff --git a/barker/barker/routers/customer_discount.py b/barker/barker/routers/customer_discount.py index 092be3c..89fe8a6 100644 --- a/barker/barker/routers/customer_discount.py +++ b/barker/barker/routers/customer_discount.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.customer as schemas from fastapi import APIRouter, Security @@ -19,25 +17,25 @@ from ..schemas.user_token import UserToken router = APIRouter() -@router.get("", response_model=List[schemas.DiscountItem]) +@router.get("", response_model=list[schemas.DiscountItem]) def show_blank( user: UserToken = Security(get_user, scopes=["customers"]), -) -> List[schemas.DiscountItem]: +) -> list[schemas.DiscountItem]: with SessionFuture() as db: return customer_discounts_blank(db) -@router.get("/{id_}", response_model=List[schemas.DiscountItem]) +@router.get("/{id_}", response_model=list[schemas.DiscountItem]) def show_id( id_: uuid.UUID, user: UserToken = Security(get_user, scopes=["customers"]), -) -> List[schemas.DiscountItem]: +) -> list[schemas.DiscountItem]: with SessionFuture() as db: item: Customer = db.execute(select(Customer).where(Customer.id == id_)).scalar_one() return customer_discounts(item, db) -def customer_discounts(item: Customer, db: Session) -> List[schemas.DiscountItem]: +def customer_discounts(item: Customer, db: Session) -> list[schemas.DiscountItem]: default_discount = ( db.execute(select(DbSetting).where(DbSetting.name == "Prefill Customer Discount")).scalar_one().data["Value"] ) @@ -58,7 +56,7 @@ def customer_discounts(item: Customer, db: Session) -> List[schemas.DiscountItem ] -def customer_discounts_blank(db: Session) -> List[schemas.DiscountItem]: +def customer_discounts_blank(db: Session) -> list[schemas.DiscountItem]: return [ schemas.DiscountItem( id=sc.id, diff --git a/barker/barker/routers/device.py b/barker/barker/routers/device.py index 1399058..c6c33b9 100644 --- a/barker/barker/routers/device.py +++ b/barker/barker/routers/device.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.device as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -57,7 +55,7 @@ def delete_route( ) -@router.get("/list", response_model=List[schemas.Device]) +@router.get("/list", response_model=list[schemas.Device]) def show_list(user: UserToken = Depends(get_user)): with SessionFuture() as db: return [device_info(item) for item in db.execute(select(Device).order_by(Device.name)).scalars().all()] diff --git a/barker/barker/routers/guest_book.py b/barker/barker/routers/guest_book.py index 79e54af..40bbdd0 100644 --- a/barker/barker/routers/guest_book.py +++ b/barker/barker/routers/guest_book.py @@ -1,7 +1,6 @@ import uuid from datetime import date, datetime, timedelta -from typing import List, Optional import barker.schemas.guest_book as schemas @@ -101,7 +100,7 @@ def show_blank( @router.get("/list", response_model=schemas.GuestBookList) def show_list( - q: Optional[str] = None, + q: str | None = None, user: UserToken = Depends(get_user), ) -> schemas.GuestBookList: if q is None or q == "": @@ -124,7 +123,7 @@ def show_list( .order_by(GuestBook.date) ) - guest_book: List[schemas.GuestBookListItem] = [] + guest_book: list[schemas.GuestBookListItem] = [] with SessionFuture() as db: for i, item in enumerate(db.execute(list_).scalars().all()): guest_book.insert( diff --git a/barker/barker/routers/login.py b/barker/barker/routers/login.py index ac5c727..5e2d097 100644 --- a/barker/barker/routers/login.py +++ b/barker/barker/routers/login.py @@ -1,7 +1,6 @@ import uuid from datetime import timedelta -from typing import Optional from fastapi import ( APIRouter, @@ -36,7 +35,7 @@ router = APIRouter() def login_for_access_token( response: Response, form_data: OAuth2PasswordRequestForm = Depends(), - device_id: Optional[uuid.UUID] = Cookie(None), + device_id: uuid.UUID | None = Cookie(None), ): with SessionFuture() as db: user = authenticate_user(form_data.username.strip(), form_data.password.strip(), db) diff --git a/barker/barker/routers/menu_category.py b/barker/barker/routers/menu_category.py index 3f1d594..8a04692 100644 --- a/barker/barker/routers/menu_category.py +++ b/barker/barker/routers/menu_category.py @@ -2,7 +2,6 @@ import uuid from datetime import date from operator import and_, or_ -from typing import List import barker.schemas.menu_category as schemas @@ -21,11 +20,11 @@ from . import effective_date router = APIRouter() -@router.post("/list", response_model=List[schemas.MenuCategory]) +@router.post("/list", response_model=list[schemas.MenuCategory]) def sort_order( - data: List[schemas.MenuCategory], + data: list[schemas.MenuCategory], user: UserToken = Security(get_user, scopes=["sections"]), -) -> List[schemas.MenuCategory]: +) -> list[schemas.MenuCategory]: try: with SessionFuture() as db: for index, item in enumerate(data): @@ -113,12 +112,12 @@ def show_blank( return menu_category_blank() -@router.get("/list", response_model=List[schemas.MenuCategory]) +@router.get("/list", response_model=list[schemas.MenuCategory]) def show_list( p: bool = False, date_: date = Depends(effective_date), user: UserToken = Depends(get_user), -) -> List[schemas.MenuCategory]: +) -> list[schemas.MenuCategory]: if p: sq = select(distinct(ProductVersion.menu_category_id)).where( and_( diff --git a/barker/barker/routers/modifier.py b/barker/barker/routers/modifier.py index f11ded7..5941437 100644 --- a/barker/barker/routers/modifier.py +++ b/barker/barker/routers/modifier.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.modifier as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -89,8 +87,8 @@ def show_blank( return modifier_blank() -@router.get("/list", response_model=List[schemas.Modifier]) -def show_list(user: UserToken = Depends(get_user)) -> List[schemas.Modifier]: +@router.get("/list", response_model=list[schemas.Modifier]) +def show_list(user: UserToken = Depends(get_user)) -> list[schemas.Modifier]: with SessionFuture() as db: return [modifier_info(item) for item in db.execute(select(Modifier).order_by(Modifier.name)).scalars().all()] diff --git a/barker/barker/routers/modifier_category.py b/barker/barker/routers/modifier_category.py index 0c6336c..d7ce4be 100644 --- a/barker/barker/routers/modifier_category.py +++ b/barker/barker/routers/modifier_category.py @@ -2,7 +2,6 @@ import uuid from datetime import date from functools import reduce -from typing import List import barker.schemas.modifier_category as schemas @@ -296,7 +295,7 @@ def modifier_category_blank(date_: date, db: Session) -> schemas.ModifierCategor ) -def add_products(modifier_category: ModifierCategory, menu_categories: List[schemas.MenuCategoryLink], db: Session): +def add_products(modifier_category: ModifierCategory, menu_categories: list[schemas.MenuCategoryLink], db: Session): for mc in menu_categories: for p in mc.products: old = next([x for x in modifier_category.products if x.id == p.id_], None) diff --git a/barker/barker/routers/printer.py b/barker/barker/routers/printer.py index fa12ea1..ac79016 100644 --- a/barker/barker/routers/printer.py +++ b/barker/barker/routers/printer.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.printer as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -85,7 +83,7 @@ def show_blank( return printer_blank() -@router.get("/list", response_model=List[schemas.Printer]) +@router.get("/list", response_model=list[schemas.Printer]) def show_list(user: UserToken = Depends(get_user)): with SessionFuture() as db: return [printer_info(item) for item in db.execute(select(Printer).order_by(Printer.name)).scalars().all()] diff --git a/barker/barker/routers/product.py b/barker/barker/routers/product.py index f8cd377..c0d4055 100644 --- a/barker/barker/routers/product.py +++ b/barker/barker/routers/product.py @@ -1,7 +1,6 @@ import uuid from datetime import date, timedelta -from typing import Dict, List, Optional import barker.schemas.product as schemas @@ -30,15 +29,15 @@ from . import effective_date router = APIRouter() -@router.post("/list", response_model=List[schemas.Product]) +@router.post("/list", response_model=list[schemas.Product]) def sort_order( - data: List[schemas.Product], + data: list[schemas.Product], date_: date = Depends(effective_date), user: UserToken = Security(get_user, scopes=["products"]), ): try: with SessionFuture() as db: - indexes: Dict[uuid.UUID, int] = {} + indexes: dict[uuid.UUID, int] = {} for item in data: if item.menu_category.id_ in indexes: indexes[item.menu_category.id_] += 1 @@ -275,13 +274,13 @@ def show_blank( ) -@router.get("/list", response_model=List[schemas.Product]) -def show_list(date_: date = Depends(effective_date), user: UserToken = Depends(get_user)) -> List[schemas.Product]: +@router.get("/list", response_model=list[schemas.Product]) +def show_list(date_: date = Depends(effective_date), user: UserToken = Depends(get_user)) -> list[schemas.Product]: with SessionFuture() as db: return product_list(date_, db) -def product_list(date_: date, db: Session) -> List[schemas.Product]: +def product_list(date_: date, db: Session) -> list[schemas.Product]: return [ product_info(item) for item in db.execute( @@ -318,8 +317,8 @@ def product_list(date_: date, db: Session) -> List[schemas.Product]: @router.get("/query") def show_term( - mc: Optional[uuid.UUID] = None, - sc: Optional[uuid.UUID] = None, + mc: uuid.UUID | None = None, + sc: uuid.UUID | None = None, date_: date = Depends(effective_date), current_user: UserToken = Depends(get_user), ): @@ -385,7 +384,7 @@ def show_term( return list_ -def product_list_of_sale_category(date_: date, db: Session) -> List[schemas.Product]: +def product_list_of_sale_category(date_: date, db: Session) -> list[schemas.Product]: return [ product_info(item) for item in db.execute( diff --git a/barker/barker/routers/reports/__init__.py b/barker/barker/routers/reports/__init__.py index 3bc27e0..495c527 100644 --- a/barker/barker/routers/reports/__init__.py +++ b/barker/barker/routers/reports/__init__.py @@ -1,5 +1,4 @@ from datetime import date, datetime, timedelta -from typing import List from barker.core.config import settings from fastapi import HTTPException, status @@ -21,7 +20,7 @@ def report_finish_date(f: str = None) -> date: ) -def check_audit_permission(start_date: date, user_permissions: List[str]): +def check_audit_permission(start_date: date, user_permissions: list[str]): today = (datetime.utcnow() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)).date() if (today - start_date).days > 5 and "audit" not in user_permissions: raise HTTPException( diff --git a/barker/barker/routers/reports/beer_sale_report.py b/barker/barker/routers/reports/beer_sale_report.py index 9895aaa..6116926 100644 --- a/barker/barker/routers/reports/beer_sale_report.py +++ b/barker/barker/routers/reports/beer_sale_report.py @@ -1,6 +1,5 @@ from datetime import date, timedelta from operator import or_ -from typing import Optional from fastapi import APIRouter, Depends, Security from sqlalchemy.sql.expression import func, select @@ -24,10 +23,10 @@ router = APIRouter() def beer_consumption( start_date: date = Depends(report_start_date), finish_date: date = Depends(report_finish_date), - r: Optional[bool] = True, - h: Optional[bool] = True, - st: Optional[bool] = True, - n: Optional[bool] = True, + r: bool | None = True, + h: bool | None = True, + st: bool | None = True, + n: bool | None = True, user: UserToken = Security(get_user, scopes=["beer-sale-report"]), ): check_audit_permission(start_date, user.permissions) diff --git a/barker/barker/routers/reports/bill_settlement_report.py b/barker/barker/routers/reports/bill_settlement_report.py index 4bcc21a..6d8be5e 100644 --- a/barker/barker/routers/reports/bill_settlement_report.py +++ b/barker/barker/routers/reports/bill_settlement_report.py @@ -1,5 +1,4 @@ from datetime import date, datetime, time, timedelta -from typing import List from fastapi import APIRouter, Depends, Security from sqlalchemy import select @@ -36,7 +35,7 @@ def bill_details( ) -def settlements(s: date, f: date, db: Session) -> List[BillSettlementItem]: +def settlements(s: date, f: date, db: Session) -> list[BillSettlementItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) @@ -77,7 +76,7 @@ def settlements(s: date, f: date, db: Session) -> List[BillSettlementItem]: return report -def reprints(s: date, f: date, db: Session) -> List[BillSettlementItem]: +def reprints(s: date, f: date, db: Session) -> list[BillSettlementItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) diff --git a/barker/barker/routers/reports/cashier_report.py b/barker/barker/routers/reports/cashier_report.py index 43ed565..49d22ca 100644 --- a/barker/barker/routers/reports/cashier_report.py +++ b/barker/barker/routers/reports/cashier_report.py @@ -1,7 +1,6 @@ import uuid from datetime import date, datetime, time, timedelta -from typing import Dict, List from fastapi import APIRouter, Cookie, Depends, Security from sqlalchemy import distinct, select @@ -29,18 +28,18 @@ from . import check_audit_permission, report_finish_date, report_start_date router = APIRouter() -@router.get("/active", response_model=List[UserLink]) +@router.get("/active", response_model=list[UserLink]) def active_cashiers( start_date: date = Depends(report_start_date), finish_date: date = Depends(report_finish_date), user: UserToken = Security(get_user, scopes=["cashier-report"]), -) -> List[UserLink]: +) -> list[UserLink]: check_audit_permission(start_date, user.permissions) with SessionFuture() as db: return get_active_cashiers(start_date, finish_date, db) -def get_active_cashiers(start_date: date, finish_date: date, db: Session) -> List[UserLink]: +def get_active_cashiers(start_date: date, finish_date: date, db: Session) -> list[UserLink]: start_datetime = datetime.combine(start_date, time()) + timedelta( minutes=settings.TIMEZONE_OFFSET_MINUTES - settings.NEW_DAY_OFFSET_MINUTES ) @@ -108,7 +107,7 @@ def get_id(id_: uuid.UUID, start_date: date, finish_date: date, user: UserLink, .all() ) - info: Dict[SettleOptionSchema, List[InfoItem]] = {} + info: dict[SettleOptionSchema, list[InfoItem]] = {} amounts = {} for item in vouchers: for so in ( diff --git a/barker/barker/routers/reports/discount_report.py b/barker/barker/routers/reports/discount_report.py index 414eb7d..8106e46 100644 --- a/barker/barker/routers/reports/discount_report.py +++ b/barker/barker/routers/reports/discount_report.py @@ -1,7 +1,6 @@ import uuid from datetime import date, datetime, time, timedelta -from typing import List from fastapi import APIRouter, Cookie, Depends, Security from sqlalchemy import func, or_, select @@ -40,7 +39,7 @@ def discount_report( ) -def get_discount_report(s: date, f: date, db: Session) -> List[DiscountReportItem]: +def get_discount_report(s: date, f: date, db: Session) -> list[DiscountReportItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) diff --git a/barker/barker/routers/reports/product_updates_report.py b/barker/barker/routers/reports/product_updates_report.py index bc489ea..e51daaf 100644 --- a/barker/barker/routers/reports/product_updates_report.py +++ b/barker/barker/routers/reports/product_updates_report.py @@ -1,5 +1,4 @@ from datetime import date, timedelta -from typing import List from fastapi import APIRouter, Depends, Security from sqlalchemy import and_, or_, select @@ -30,8 +29,8 @@ def product_updates_report_view( } -def product_updates_report(s: date, f: date, db: Session) -> List[str]: - list_: List[ProductVersion] = ( +def product_updates_report(s: date, f: date, db: Session) -> list[str]: + list_: list[ProductVersion] = ( db.execute( select(ProductVersion) .join(ProductVersion.menu_category) diff --git a/barker/barker/routers/reports/sale_report.py b/barker/barker/routers/reports/sale_report.py index 9c448b3..5cec538 100644 --- a/barker/barker/routers/reports/sale_report.py +++ b/barker/barker/routers/reports/sale_report.py @@ -1,7 +1,6 @@ import uuid from datetime import date, datetime, time, timedelta -from typing import List from fastapi import APIRouter, Cookie, Depends, Security from sqlalchemy import func, or_, select @@ -51,7 +50,7 @@ def get_sale_report( ) -def get_sale(s: date, f: date, db: Session) -> List[SaleReportItem]: +def get_sale(s: date, f: date, db: Session) -> list[SaleReportItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) @@ -91,7 +90,7 @@ def get_sale(s: date, f: date, db: Session) -> List[SaleReportItem]: return info + [SaleReportItem(name="Total Settled", amount=total)] -def get_settlements(s: date, f: date, db: Session) -> List[SaleReportItem]: +def get_settlements(s: date, f: date, db: Session) -> list[SaleReportItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) diff --git a/barker/barker/routers/reports/tax_report.py b/barker/barker/routers/reports/tax_report.py index d34a883..a721199 100644 --- a/barker/barker/routers/reports/tax_report.py +++ b/barker/barker/routers/reports/tax_report.py @@ -2,7 +2,6 @@ import re from datetime import date, datetime, time, timedelta from decimal import Decimal -from typing import List from fastapi import APIRouter, Depends, Security from sqlalchemy import func, select @@ -39,7 +38,7 @@ def get_tax_report( ) -def get_tax(s: date, f: date, db: Session) -> List[TaxReportItem]: +def get_tax(s: date, f: date, db: Session) -> list[TaxReportItem]: start_date = datetime.combine(s, time()) + timedelta( minutes=settings.NEW_DAY_OFFSET_MINUTES - settings.TIMEZONE_OFFSET_MINUTES ) @@ -68,7 +67,7 @@ def get_tax(s: date, f: date, db: Session) -> List[TaxReportItem]: return sum([get_tax_item(*i) for i in amounts], []) -def get_tax_item(name: str, rate: Decimal, net: Decimal, amount: Decimal) -> List[TaxReportItem]: +def get_tax_item(name: str, rate: Decimal, net: Decimal, amount: Decimal) -> list[TaxReportItem]: items = name.split(";") if len(items) == 1: return [TaxReportItem(name=name, taxRate=rate, saleAmount=net, amount=amount)] diff --git a/barker/barker/routers/role.py b/barker/barker/routers/role.py index 2712d94..9ac9973 100644 --- a/barker/barker/routers/role.py +++ b/barker/barker/routers/role.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.role as schemas from fastapi import APIRouter, HTTPException, Security, status @@ -91,10 +89,10 @@ def show_blank( return role_blank(db) -@router.get("/list", response_model=List[schemas.RoleList]) +@router.get("/list", response_model=list[schemas.RoleList]) def show_list( user: UserToken = Security(get_user, scopes=["users"]), -) -> List[schemas.RoleList]: +) -> list[schemas.RoleList]: with SessionFuture() as db: return [ schemas.RoleList( @@ -141,7 +139,7 @@ def role_blank(db: Session) -> schemas.RoleBlank: ) -def add_permissions(role: Role, permissions: List[schemas.PermissionItem], db: Session): +def add_permissions(role: Role, permissions: list[schemas.PermissionItem], db: Session): for permission in permissions: gp = next([p for p in role.permissions if p.id == permission.id_], None) if permission.enabled and gp is None: diff --git a/barker/barker/routers/sale_category.py b/barker/barker/routers/sale_category.py index 54da05d..cfdbc05 100644 --- a/barker/barker/routers/sale_category.py +++ b/barker/barker/routers/sale_category.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.sale_category as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -82,8 +80,8 @@ def show_blank( return sale_category_blank() -@router.get("/list", response_model=List[schemas.SaleCategory]) -def show_list(user: UserToken = Depends(get_user)) -> List[schemas.SaleCategory]: +@router.get("/list", response_model=list[schemas.SaleCategory]) +def show_list(user: UserToken = Depends(get_user)) -> list[schemas.SaleCategory]: with SessionFuture() as db: return [ sale_category_info(item) diff --git a/barker/barker/routers/section.py b/barker/barker/routers/section.py index c628fc8..4fea5ef 100644 --- a/barker/barker/routers/section.py +++ b/barker/barker/routers/section.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.section as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -95,7 +93,7 @@ def show_blank( return section_blank() -@router.get("/list", response_model=List[schemas.Section]) +@router.get("/list", response_model=list[schemas.Section]) def show_list(user: UserToken = Depends(get_user)): with SessionFuture() as db: return [section_info(item) for item in db.execute(select(Section).order_by(Section.name)).scalars().all()] diff --git a/barker/barker/routers/section_printer.py b/barker/barker/routers/section_printer.py index 8deec85..0e0d135 100644 --- a/barker/barker/routers/section_printer.py +++ b/barker/barker/routers/section_printer.py @@ -1,7 +1,5 @@ import uuid -from typing import List, Optional - import barker.schemas.section_printer as schemas from fastapi import APIRouter, HTTPException, Security, status @@ -20,12 +18,12 @@ from ..schemas.user_token import UserToken router = APIRouter() -@router.post("/{id_}", response_model=List[schemas.SectionPrinter]) +@router.post("/{id_}", response_model=list[schemas.SectionPrinter]) def save( id_: uuid.UUID, - data: List[schemas.SectionPrinter], + data: list[schemas.SectionPrinter], user: UserToken = Security(get_user, scopes=["section-printers"]), -) -> List[schemas.SectionPrinter]: +) -> list[schemas.SectionPrinter]: try: with SessionFuture() as db: current = [] @@ -77,11 +75,11 @@ def save( ) -@router.delete("/{id_}", response_model=List[schemas.SectionPrinter]) +@router.delete("/{id_}", response_model=list[schemas.SectionPrinter]) def delete_route( id_: uuid.UUID, user: UserToken = Security(get_user, scopes=["section-printers"]), -) -> List[schemas.SectionPrinter]: +) -> list[schemas.SectionPrinter]: try: with SessionFuture() as db: db.execute(delete(SectionPrinter).where(SectionPrinter.section_id == id_)) @@ -94,24 +92,24 @@ def delete_route( ) -@router.get("", response_model=List[schemas.SectionPrinter]) +@router.get("", response_model=list[schemas.SectionPrinter]) def show_blank( user: UserToken = Security(get_user, scopes=["section-printers"]), -) -> List[schemas.SectionPrinter]: +) -> list[schemas.SectionPrinter]: with SessionFuture() as db: return report(None, db) -@router.get("/{id_}", response_model=List[schemas.SectionPrinter]) +@router.get("/{id_}", response_model=list[schemas.SectionPrinter]) def show_id( id_: uuid.UUID, user: UserToken = Security(get_user, scopes=["section-printers"]), -) -> List[schemas.SectionPrinter]: +) -> list[schemas.SectionPrinter]: with SessionFuture() as db: return report(id_, db) -def report(section_id: Optional[uuid.UUID], db: Session) -> List[schemas.SectionPrinter]: +def report(section_id: uuid.UUID | None, db: Session) -> list[schemas.SectionPrinter]: sale_categories = db.execute(select(SaleCategory.id, SaleCategory.name).order_by(SaleCategory.name)).all() list_ = [] for sc_id, sc_name in [(None, None)] + sale_categories: diff --git a/barker/barker/routers/settle_option.py b/barker/barker/routers/settle_option.py index 597b625..c8fc0dd 100644 --- a/barker/barker/routers/settle_option.py +++ b/barker/barker/routers/settle_option.py @@ -1,5 +1,3 @@ -from typing import List - import barker.schemas.settle_option as schemas from fastapi import APIRouter, Depends, HTTPException, Security, status @@ -106,7 +104,7 @@ def show_blank( return settle_option_blank() -@router.get("/list", response_model=List[schemas.SettleOption]) +@router.get("/list", response_model=list[schemas.SettleOption]) def show_list(user: UserToken = Depends(get_user)): with SessionFuture() as db: return [ @@ -115,7 +113,7 @@ def show_list(user: UserToken = Depends(get_user)): ] -@router.get("/for-type/{vt}", response_model=List[schemas.SettleOption]) +@router.get("/for-type/{vt}", response_model=list[schemas.SettleOption]) def show_list_for_type(vt: VoucherType, user: UserToken = Depends(get_user)): with SessionFuture() as db: return [ diff --git a/barker/barker/routers/table.py b/barker/barker/routers/table.py index 75ff29b..3d63c21 100644 --- a/barker/barker/routers/table.py +++ b/barker/barker/routers/table.py @@ -1,7 +1,6 @@ import uuid from datetime import timedelta -from typing import List, Union import barker.schemas.table as schemas @@ -20,11 +19,11 @@ from ..schemas.user_token import UserToken router = APIRouter() -@router.post("/list", response_model=List[schemas.Table]) +@router.post("/list", response_model=list[schemas.Table]) def sort_order( - data: List[schemas.Table], + data: list[schemas.Table], user: UserToken = Security(get_user, scopes=["sections"]), -) -> List[schemas.Table]: +) -> list[schemas.Table]: try: with SessionFuture() as db: for index, item in enumerate(data): @@ -118,7 +117,7 @@ def show_blank( return food_table_blank() -@router.get("/list", response_model=List[schemas.Table]) +@router.get("/list", response_model=list[schemas.Table]) def show_list(user: UserToken = Depends(get_user)): with SessionFuture() as db: return [ @@ -163,11 +162,11 @@ def show_running(user: UserToken = Depends(get_user)): return food_tables -@router.get("/from-voucher/{id_}", response_model=Union[schemas.Table, schemas.TableBlank]) +@router.get("/from-voucher/{id_}", response_model=schemas.Table | schemas.TableBlank) def show_voucher( id_: uuid.UUID, user: UserToken = Security(get_user), -) -> Union[schemas.Table, schemas.TableBlank]: +) -> schemas.Table | schemas.TableBlank: with SessionFuture() as db: overview: Overview = db.execute(select(Overview).where(Overview.voucher_id == id_)).scalars().one_or_none() if overview is not None: diff --git a/barker/barker/routers/tax.py b/barker/barker/routers/tax.py index beedc5d..09b4644 100644 --- a/barker/barker/routers/tax.py +++ b/barker/barker/routers/tax.py @@ -2,7 +2,6 @@ import re import uuid from decimal import Decimal -from typing import List import barker.schemas.tax as schemas @@ -109,8 +108,8 @@ def show_blank( return tax_blank() -@router.get("/list", response_model=List[schemas.Tax]) -def show_list(user: UserToken = Depends(get_user)) -> List[schemas.Tax]: +@router.get("/list", response_model=list[schemas.Tax]) +def show_list(user: UserToken = Depends(get_user)) -> list[schemas.Tax]: with SessionFuture() as db: return [tax_info(item) for item in db.execute(select(Tax).order_by(Tax.name)).scalars().all()] diff --git a/barker/barker/routers/temporal_product.py b/barker/barker/routers/temporal_product.py index 254f051..be628da 100644 --- a/barker/barker/routers/temporal_product.py +++ b/barker/barker/routers/temporal_product.py @@ -1,7 +1,6 @@ import uuid from datetime import date, timedelta -from typing import Dict, List import barker.schemas.product as schemas @@ -176,14 +175,14 @@ def delete_route( return -@router.get("/list", response_model=List[List[schemas.Product]]) -def show_list(user: UserToken = Security(get_user, scopes=["temporal-products"])) -> List[List[schemas.Product]]: +@router.get("/list", response_model=list[list[schemas.Product]]) +def show_list(user: UserToken = Security(get_user, scopes=["temporal-products"])) -> list[list[schemas.Product]]: with SessionFuture() as db: return product_list(db) -def product_list(db: Session) -> List[List[schemas.Product]]: - dict_: Dict[uuid.UUID, List[schemas.Product]] = {} +def product_list(db: Session) -> list[list[schemas.Product]]: + dict_: dict[uuid.UUID, list[schemas.Product]] = {} list_ = ( db.execute( select(ProductVersion) diff --git a/barker/barker/routers/update_product_prices.py b/barker/barker/routers/update_product_prices.py index e899ac2..728ea56 100644 --- a/barker/barker/routers/update_product_prices.py +++ b/barker/barker/routers/update_product_prices.py @@ -2,7 +2,6 @@ import uuid from datetime import date, timedelta from decimal import Decimal -from typing import List, Optional from fastapi import APIRouter, Depends, HTTPException, Security, status from sqlalchemy import and_, or_, select @@ -22,7 +21,7 @@ router = APIRouter() @router.get("", response_model=UpdateProductPrices) def get_update_product_prices( - date_: Optional[date] = Depends(optional_query_date), + date_: date | None = Depends(optional_query_date), user: UserToken = Security(get_user, scopes=["products"]), ) -> UpdateProductPrices: if date_ is None: @@ -40,7 +39,7 @@ def get_update_product_prices( @router.get("/{id_}", response_model=UpdateProductPrices) def get_update_product_prices_id( id_: uuid.UUID, - date_: Optional[date] = Depends(optional_query_date), + date_: date | None = Depends(optional_query_date), user: UserToken = Security(get_user, scopes=["products"]), ) -> UpdateProductPrices: if date_ is None: @@ -58,8 +57,8 @@ def get_update_product_prices_id( def update_product_prices_list( - menu_category_id: Optional[uuid.UUID], date_: date, db: Session -) -> List[UpdateProductPricesItem]: + menu_category_id: uuid.UUID | None, date_: date, db: Session +) -> list[UpdateProductPricesItem]: list_ = ( select(ProductVersion) .join(ProductVersion.menu_category) diff --git a/barker/barker/routers/user.py b/barker/barker/routers/user.py index fbf173b..0925801 100644 --- a/barker/barker/routers/user.py +++ b/barker/barker/routers/user.py @@ -1,7 +1,5 @@ import uuid -from typing import List - import barker.schemas.user as schemas from barker.core.security import get_current_active_user as get_user @@ -93,7 +91,7 @@ def update_route( ) -def add_roles(user: User, roles: List[schemas.RoleItem], db: Session): +def add_roles(user: User, roles: list[schemas.RoleItem], db: Session): for role in roles: ug = next([g for g in user.roles if g.id == role.id_], None) if role.enabled and ug is None: @@ -132,10 +130,10 @@ def show_blank( return blank_user_info(db) -@router.get("/list", response_model=List[schemas.UserList]) +@router.get("/list", response_model=list[schemas.UserList]) def show_list( user: UserToken = Security(get_user, scopes=["users"]), -) -> List[schemas.UserList]: +) -> list[schemas.UserList]: with SessionFuture() as db: return [ schemas.UserList( diff --git a/barker/barker/routers/voucher/__init__.py b/barker/barker/routers/voucher/__init__.py index 216f04f..ff4a9fb 100644 --- a/barker/barker/routers/voucher/__init__.py +++ b/barker/barker/routers/voucher/__init__.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import List, Optional import barker.schemas.voucher as schemas @@ -30,7 +29,7 @@ def get_tax(tax, voucher_type): ) -def get_bill_id(voucher_type: VoucherType, db: Session) -> Optional[int]: +def get_bill_id(voucher_type: VoucherType, db: Session) -> int | None: if voucher_type == VoucherType.KOT: return None bill_id = db.execute( @@ -41,7 +40,7 @@ def get_bill_id(voucher_type: VoucherType, db: Session) -> Optional[int]: return bill_id -def do_update_table(item: Voucher, guest_book: Optional[GuestBook], db: Session): +def do_update_table(item: Voucher, guest_book: GuestBook | None, db: Session): status_ = "running" if item.voucher_type == VoucherType.KOT else "printed" if item.status is None: item.status = Overview( @@ -55,7 +54,7 @@ def do_update_table(item: Voucher, guest_book: Optional[GuestBook], db: Session) item.status.status = status_ -def check_permissions(item: Optional[Voucher], voucher_type: VoucherType, permissions: List[str]): +def check_permissions(item: Voucher | None, voucher_type: VoucherType, permissions: list[str]): if voucher_type == VoucherType.KOT and "print-kot" not in permissions: raise HTTPException( status_code=status.HTTP_403_FORBIDDEN, @@ -88,15 +87,15 @@ def check_permissions(item: Optional[Voucher], voucher_type: VoucherType, permis ) -def get_guest_book(id_: Optional[uuid.UUID], db: Session) -> Optional[GuestBook]: +def get_guest_book(id_: uuid.UUID | None, db: Session) -> GuestBook | None: if id_ is None: return id_ return db.execute(select(GuestBook).where(GuestBook.id == id_)).scalar_one() -def do_update_settlements(voucher: Voucher, others: List[SettleSchema], db: Session) -> bool: +def do_update_settlements(voucher: Voucher, others: list[SettleSchema], db: Session) -> bool: fully_settled = True - settlements: List[SettleSchema] = [] + settlements: list[SettleSchema] = [] settlements += others total_amount = voucher.amount settlements.append(SettleSchema(id=SettleOption.AMOUNT(), amount=-total_amount)) @@ -128,14 +127,14 @@ def do_update_settlements(voucher: Voucher, others: List[SettleSchema], db: Sess return fully_settled -def happy_hour_items_balanced(inventories: List[schemas.Inventory]) -> bool: +def happy_hour_items_balanced(inventories: list[schemas.Inventory]) -> bool: happy = set((i.product.id_, i.quantity) for i in inventories if i.is_happy_hour) products = set(i.product.id_ for i in inventories if i.is_happy_hour) other = set((i.product.id_, i.quantity) for i in inventories if not i.is_happy_hour and i.product.id_ in products) return happy == other -def happy_hour_has_discount(inventories: List[schemas.Inventory]) -> bool: +def happy_hour_has_discount(inventories: list[schemas.Inventory]) -> bool: happy = set(i.product.id_ for i in inventories if i.is_happy_hour) offenders = [i for i in inventories if i.product.id_ in happy and i.discount != 0] return len(offenders) > 0 @@ -143,7 +142,7 @@ def happy_hour_has_discount(inventories: List[schemas.Inventory]) -> bool: # This is for the whole bill. eg. Kot 1 => Reg 2 + HH 2; Kot 2 => Reg 4; Kot 3 => Reg - 4 # This is pass okay in happy hours items balanced, but overall this is wrong. Hence this check -def happy_hour_items_more_than_regular(kots: List[schemas.Kot]) -> bool: +def happy_hour_items_more_than_regular(kots: list[schemas.Kot]) -> bool: inventories = {} for kot in kots: for inventory in kot.inventories: diff --git a/barker/barker/routers/voucher/change.py b/barker/barker/routers/voucher/change.py index bee6828..5d9927d 100644 --- a/barker/barker/routers/voucher/change.py +++ b/barker/barker/routers/voucher/change.py @@ -1,7 +1,5 @@ import uuid -from typing import Optional - import barker.schemas.voucher as schemas from fastapi import APIRouter, HTTPException, Security, status @@ -32,7 +30,7 @@ def change( id_: uuid.UUID, data: schemas.VoucherIn, u: bool, # Update table? - g: Optional[uuid.UUID] = None, # Guest book id + g: uuid.UUID | None = None, # Guest book id user: UserToken = Security(get_user, scopes=["edit-printed-bill"]), ): try: @@ -75,7 +73,7 @@ def reprint_bill(voucher_id: uuid.UUID, user_id: uuid.UUID, db: Session): def void_and_issue_new_bill( data: schemas.VoucherIn, u: bool, - g: Optional[uuid.UUID], + g: uuid.UUID | None, old: Voucher, db: Session, user: UserToken, diff --git a/barker/barker/routers/voucher/merge_move.py b/barker/barker/routers/voucher/merge_move.py index 94308d5..bfa99dd 100644 --- a/barker/barker/routers/voucher/merge_move.py +++ b/barker/barker/routers/voucher/merge_move.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime -from typing import List import barker.schemas.merge_move as schemas @@ -137,7 +136,7 @@ def merge_table( ) -def update_settlements(vouchers: List[uuid.UUID], db: Session): +def update_settlements(vouchers: list[uuid.UUID], db: Session): for v in vouchers: voucher: Voucher = db.execute(select(Voucher).where(Voucher.id == v)).scalar_one() do_update_settlements(voucher, [], db) diff --git a/barker/barker/routers/voucher/save.py b/barker/barker/routers/voucher/save.py index 9bb619d..bb591cc 100644 --- a/barker/barker/routers/voucher/save.py +++ b/barker/barker/routers/voucher/save.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime, timedelta -from typing import Optional import barker.schemas.voucher as schemas @@ -43,7 +42,7 @@ def save( data: schemas.VoucherIn, u: bool, # Update table? p: int, # Print type - g: Optional[uuid.UUID] = None, # Guest book id + g: uuid.UUID | None = None, # Guest book id user: UserToken = Security(get_user), ): try: @@ -70,7 +69,7 @@ def save( def do_save( data: schemas.VoucherIn, voucher_type: VoucherType, - guest_book: Optional[GuestBook], + guest_book: GuestBook | None, db: Session, user: UserToken, ): diff --git a/barker/barker/routers/voucher/show.py b/barker/barker/routers/voucher/show.py index ca8b8c4..fcf1217 100644 --- a/barker/barker/routers/voucher/show.py +++ b/barker/barker/routers/voucher/show.py @@ -2,7 +2,6 @@ import re import uuid from datetime import datetime, timedelta -from typing import Optional from fastapi import APIRouter, HTTPException, Security, status from sqlalchemy import and_, or_, select @@ -81,8 +80,8 @@ def from_bill( @router.get("/from-table/{id_}") def from_table( id_: str, # table id - v: Optional[uuid.UUID] = None, # voucher id - g: Optional[uuid.UUID] = None, # guest id + v: uuid.UUID | None = None, # voucher id + g: uuid.UUID | None = None, # guest id user: UserToken = Security(get_user), ): with SessionFuture() as db: @@ -204,7 +203,7 @@ def voucher_info(item: Voucher, db: Session): } -def voucher_blank(table: FoodTable, guest: Optional[GuestBook]): +def voucher_blank(table: FoodTable, guest: GuestBook | None): return { "pax": table.seats if guest is None else guest.pax, "table": {"id": table.id, "name": table.name}, diff --git a/barker/barker/routers/voucher/split.py b/barker/barker/routers/voucher/split.py index 57f4078..a9c635a 100644 --- a/barker/barker/routers/voucher/split.py +++ b/barker/barker/routers/voucher/split.py @@ -3,7 +3,6 @@ import uuid from collections import defaultdict from datetime import datetime from decimal import Decimal -from typing import Dict, List, Optional, Tuple import barker.schemas.split as schemas @@ -91,12 +90,12 @@ def split( def save( - inventories: List[Inventory], + inventories: list[Inventory], now: datetime, voucher_type: VoucherType, pax: int, table_id: uuid.UUID, - customer_id: Optional[uuid.UUID], + customer_id: uuid.UUID | None, user_id: uuid.UUID, db: Session, ): @@ -156,22 +155,22 @@ def save( return item -def split_into_kots(inventories: List[Inventory]) -> list: +def split_into_kots(inventories: list[Inventory]) -> list: kots = defaultdict(list) for item in inventories: kots[item.kot_id].append(item) return [k for k in kots.values() if len(k) > 0] -def happy_hour_items_balanced(inventories: List[Inventory]) -> bool: +def happy_hour_items_balanced(inventories: list[Inventory]) -> bool: happy = set((i.product_id, i.quantity) for i in inventories if i.is_happy_hour) products = set(i.product_id for i in inventories if i.is_happy_hour) other = set((i.product_id, i.quantity) for i in inventories if not i.is_happy_hour and i.product_id in products) return happy == other -def are_product_quantities_positive(inventories: List[Inventory]) -> bool: - quantities: Dict[Tuple[uuid.UUID, bool], Decimal] = defaultdict(Decimal) +def are_product_quantities_positive(inventories: list[Inventory]) -> bool: + quantities: dict[tuple[uuid.UUID, bool], Decimal] = defaultdict(Decimal) for i in inventories: key = (i.product_id, i.is_happy_hour) quantities[key] += i.quantity @@ -181,7 +180,7 @@ def are_product_quantities_positive(inventories: List[Inventory]) -> bool: return True -def happy_hour_items_more_than_regular(invs: List[Inventory]) -> bool: +def happy_hour_items_more_than_regular(invs: list[Inventory]) -> bool: inventories = {} for inventory in invs: if inventory.product_id not in inventories: diff --git a/barker/barker/routers/voucher/update.py b/barker/barker/routers/voucher/update.py index 9fc9b99..5b7c787 100644 --- a/barker/barker/routers/voucher/update.py +++ b/barker/barker/routers/voucher/update.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime, timedelta -from typing import Optional import barker.schemas.voucher as schemas @@ -43,7 +42,7 @@ def update_route( data: schemas.VoucherIn, u: bool, # Update table? p: int, # Print type - g: Optional[uuid.UUID] = None, # Guest book id + g: uuid.UUID | None = None, # Guest book id user: UserToken = Security(get_user), ): try: diff --git a/barker/barker/schemas/bill_settlement_report.py b/barker/barker/schemas/bill_settlement_report.py index ff4c6f7..f497759 100644 --- a/barker/barker/schemas/bill_settlement_report.py +++ b/barker/barker/schemas/bill_settlement_report.py @@ -1,6 +1,5 @@ from datetime import date, datetime from decimal import Decimal -from typing import List from pydantic import BaseModel, validator @@ -30,7 +29,7 @@ class BillSettlementItem(BaseModel): class BillSettlement(BaseModel): start_date: date finish_date: date - amounts: List[BillSettlementItem] + amounts: list[BillSettlementItem] class Config: anystr_strip_whitespace = True diff --git a/barker/barker/schemas/cashier_report.py b/barker/barker/schemas/cashier_report.py index 317582d..9904877 100644 --- a/barker/barker/schemas/cashier_report.py +++ b/barker/barker/schemas/cashier_report.py @@ -1,6 +1,5 @@ from datetime import date, datetime from decimal import Decimal -from typing import Dict, List from pydantic import BaseModel, validator @@ -54,8 +53,8 @@ class CashierReport(BaseModel): cashier: UserLink cashiers: str user: UserLink - amounts: List[NameAmount] - info: Dict[str, List[InfoItem]] + amounts: list[NameAmount] + info: dict[str, list[InfoItem]] class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/customer.py b/barker/barker/schemas/customer.py index 61fb13f..15e9b4d 100644 --- a/barker/barker/schemas/customer.py +++ b/barker/barker/schemas/customer.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import List, Optional from pydantic import BaseModel, Field @@ -12,8 +11,8 @@ class DiscountItem(BaseModel): id_: uuid.UUID name: str discount: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1) - discount_limit: Optional[Decimal] - customer_discount: Optional[Decimal] + discount_limit: Decimal | None + customer_discount: Decimal | None class Config: alias_generator = to_camel @@ -23,10 +22,10 @@ class CustomerIn(BaseModel): name: str = Field(..., min_length=1) # phone: str = Field(..., min_length=1) phone: str - address: Optional[str] + address: str | None print_in_bill: bool - discounts: List[DiscountItem] + discounts: list[DiscountItem] class Config: anystr_strip_whitespace = True @@ -44,7 +43,7 @@ class Customer(CustomerIn): class CustomerLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/device.py b/barker/barker/schemas/device.py index 3101664..f0f1989 100644 --- a/barker/barker/schemas/device.py +++ b/barker/barker/schemas/device.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime -from typing import Optional from pydantic import BaseModel, Field @@ -23,7 +22,7 @@ class Device(DeviceIn): id_: uuid.UUID creation_date: datetime last_user: str - last_date: Optional[datetime] + last_date: datetime | None class Config: fields = {"id_": "id"} @@ -34,7 +33,7 @@ class Device(DeviceIn): class DeviceLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/discount_report.py b/barker/barker/schemas/discount_report.py index 9617fcd..5b14806 100644 --- a/barker/barker/schemas/discount_report.py +++ b/barker/barker/schemas/discount_report.py @@ -1,6 +1,5 @@ from datetime import date, datetime from decimal import Decimal -from typing import List from pydantic import BaseModel, validator @@ -19,7 +18,7 @@ class DiscountReportItem(BaseModel): class DiscountReport(BaseModel): start_date: date finish_date: date - amounts: List[DiscountReportItem] + amounts: list[DiscountReportItem] class Config: anystr_strip_whitespace = True diff --git a/barker/barker/schemas/guest_book.py b/barker/barker/schemas/guest_book.py index 76ff8b0..40b02c4 100644 --- a/barker/barker/schemas/guest_book.py +++ b/barker/barker/schemas/guest_book.py @@ -1,7 +1,6 @@ import uuid from datetime import date, datetime -from typing import List, Optional from pydantic import BaseModel, Field, validator @@ -11,7 +10,7 @@ from . import to_camel class GuestBookIn(BaseModel): name: str phone: str - address: Optional[str] + address: str | None pax: int = Field(ge=0) class Config: @@ -44,10 +43,10 @@ class GuestBookListItem(BaseModel): phone: str pax: int date_: datetime - status: Optional[str] - table_id: Optional[uuid.UUID] - voucher_id: Optional[uuid.UUID] - table_name: Optional[str] + status: str | None + table_id: uuid.UUID | None + voucher_id: uuid.UUID | None + table_name: str | None @validator("date_", pre=True) def parse_date(cls, value): @@ -64,7 +63,7 @@ class GuestBookListItem(BaseModel): class GuestBookList(BaseModel): date_: date - list: List[GuestBookListItem] + list: list[GuestBookListItem] @validator("date_", pre=True) def parse_date(cls, value): diff --git a/barker/barker/schemas/master.py b/barker/barker/schemas/master.py index 40fd573..fcdc2be 100644 --- a/barker/barker/schemas/master.py +++ b/barker/barker/schemas/master.py @@ -2,7 +2,6 @@ import uuid from datetime import date, datetime from decimal import Decimal -from typing import Optional from pydantic import BaseModel, Field, validator @@ -36,7 +35,7 @@ class EmployeeIn(AccountBase): salary: int = Field(ge=0) points: Decimal = Field(ge=0, lt=1000, multiple_of=0.01) joining_date: date - leaving_date: Optional[date] + leaving_date: date | None @validator("joining_date", pre=True) def parse_joining_date(cls, value): diff --git a/barker/barker/schemas/menu_category.py b/barker/barker/schemas/menu_category.py index 15569d9..2dd7eec 100644 --- a/barker/barker/schemas/menu_category.py +++ b/barker/barker/schemas/menu_category.py @@ -1,7 +1,5 @@ import uuid -from typing import List, Optional - from pydantic import BaseModel, Field from . import to_camel @@ -37,8 +35,8 @@ class MenuCategoryBlank(MenuCategoryIn): class MenuCategoryLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] - products: List[ProductLink] + name: str | None + products: list[ProductLink] class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/modifier.py b/barker/barker/schemas/modifier.py index 715899c..15226bb 100644 --- a/barker/barker/schemas/modifier.py +++ b/barker/barker/schemas/modifier.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import Optional from pydantic import BaseModel, Field @@ -28,7 +27,7 @@ class Modifier(ModifierIn): class ModifierLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} @@ -36,7 +35,7 @@ class ModifierLink(BaseModel): class ModifierBlank(ModifierIn): name: str - modifier_category: Optional[ModifierCategoryLink] + modifier_category: ModifierCategoryLink | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/modifier_category.py b/barker/barker/schemas/modifier_category.py index 040aae7..e510788 100644 --- a/barker/barker/schemas/modifier_category.py +++ b/barker/barker/schemas/modifier_category.py @@ -1,7 +1,5 @@ import uuid -from typing import List, Optional - from pydantic import BaseModel, Field from . import to_camel @@ -11,9 +9,9 @@ from .menu_category import MenuCategoryLink class ModifierCategoryIn(BaseModel): name: str = Field(..., min_length=1) minimum: int = Field(ge=0) - maximum: Optional[int] = Field(ge=0) + maximum: int | None = Field(ge=0) is_active: bool - menu_categories: List[MenuCategoryLink] + menu_categories: list[MenuCategoryLink] class Config: anystr_strip_whitespace = True @@ -40,7 +38,7 @@ class ModifierCategoryBlank(ModifierCategoryIn): class ModifierCategoryLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/product.py b/barker/barker/schemas/product.py index 394cb17..838460f 100644 --- a/barker/barker/schemas/product.py +++ b/barker/barker/schemas/product.py @@ -2,7 +2,6 @@ import uuid from datetime import date, datetime from decimal import Decimal -from typing import Optional from pydantic import BaseModel, Field, validator @@ -31,8 +30,8 @@ class ProductIn(BaseModel): class Product(ProductIn): id_: uuid.UUID version_id: uuid.UUID - valid_from: Optional[date] - valid_till: Optional[date] + valid_from: date | None + valid_till: date | None class Config: anystr_strip_whitespace = True @@ -58,8 +57,8 @@ class Product(ProductIn): class ProductBlank(ProductIn): name: str - menu_category: Optional[MenuCategoryLink] - sale_category: Optional[SaleCategoryLink] + menu_category: MenuCategoryLink | None + sale_category: SaleCategoryLink | None class Config: anystr_strip_whitespace = True diff --git a/barker/barker/schemas/product_link.py b/barker/barker/schemas/product_link.py index b92d147..51f2476 100644 --- a/barker/barker/schemas/product_link.py +++ b/barker/barker/schemas/product_link.py @@ -1,14 +1,12 @@ import uuid -from typing import Optional - from pydantic import BaseModel, Field class ProductLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] - enabled: Optional[bool] + name: str | None + enabled: bool | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/receive_payment.py b/barker/barker/schemas/receive_payment.py index ff43de6..7efe0bb 100644 --- a/barker/barker/schemas/receive_payment.py +++ b/barker/barker/schemas/receive_payment.py @@ -1,5 +1,4 @@ from decimal import Decimal -from typing import List from pydantic import BaseModel @@ -16,7 +15,7 @@ class ReceivePaymentItem(BaseModel): class ReceivePayment(BaseModel): reason: str - amounts: List[ReceivePaymentItem] + amounts: list[ReceivePaymentItem] class Config: alias_generator = to_camel diff --git a/barker/barker/schemas/role.py b/barker/barker/schemas/role.py index 87d1fef..462a7b3 100644 --- a/barker/barker/schemas/role.py +++ b/barker/barker/schemas/role.py @@ -1,14 +1,12 @@ import uuid -from typing import List - from barker.schemas.permission import PermissionItem from pydantic import BaseModel, Field class RoleIn(BaseModel): name: str = Field(..., min_length=1) - permissions: List[PermissionItem] + permissions: list[PermissionItem] class Config: anystr_strip_whitespace = True @@ -32,7 +30,7 @@ class RoleBlank(RoleIn): class RoleList(BaseModel): id_: uuid.UUID name: str - permissions: List[str] + permissions: list[str] class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/sale_category.py b/barker/barker/schemas/sale_category.py index 629b08a..3dc3e2c 100644 --- a/barker/barker/schemas/sale_category.py +++ b/barker/barker/schemas/sale_category.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import Optional from pydantic import BaseModel, Field @@ -29,7 +28,7 @@ class SaleCategory(SaleCategoryIn): class SaleCategoryBlank(SaleCategoryIn): name: str - tax: Optional[TaxLink] + tax: TaxLink | None class Config: anystr_strip_whitespace = True @@ -38,7 +37,7 @@ class SaleCategoryBlank(SaleCategoryIn): class SaleCategoryForDiscount(SaleCategory): discount: Decimal - tax: Optional[TaxLink] + tax: TaxLink | None class Config: anystr_strip_whitespace = True @@ -47,7 +46,7 @@ class SaleCategoryForDiscount(SaleCategory): class SaleCategoryLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/sale_report.py b/barker/barker/schemas/sale_report.py index 21d4c7f..5cd55b5 100644 --- a/barker/barker/schemas/sale_report.py +++ b/barker/barker/schemas/sale_report.py @@ -1,6 +1,5 @@ from datetime import date, datetime from decimal import Decimal -from typing import List from pydantic import BaseModel, validator @@ -20,7 +19,7 @@ class SaleReportItem(BaseModel): class SaleReport(BaseModel): start_date: date finish_date: date - amounts: List[SaleReportItem] + amounts: list[SaleReportItem] user: UserLink class Config: diff --git a/barker/barker/schemas/section.py b/barker/barker/schemas/section.py index 1934ac4..9e14d6a 100644 --- a/barker/barker/schemas/section.py +++ b/barker/barker/schemas/section.py @@ -1,7 +1,5 @@ import uuid -from typing import Optional - from pydantic import BaseModel, Field @@ -29,7 +27,7 @@ class SectionBlank(BaseModel): class SectionLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/section_printer.py b/barker/barker/schemas/section_printer.py index 6f4da26..647348c 100644 --- a/barker/barker/schemas/section_printer.py +++ b/barker/barker/schemas/section_printer.py @@ -1,5 +1,3 @@ -from typing import Optional - from pydantic import BaseModel, Field from . import to_camel @@ -8,8 +6,8 @@ from .sale_category import SaleCategoryLink class SectionPrinter(BaseModel): - sale_category: Optional[SaleCategoryLink] - printer: Optional[PrinterLink] + sale_category: SaleCategoryLink | None + printer: PrinterLink | None copies: int = Field(ge=0) class Config: diff --git a/barker/barker/schemas/split.py b/barker/barker/schemas/split.py index cf9ed03..4013f1b 100644 --- a/barker/barker/schemas/split.py +++ b/barker/barker/schemas/split.py @@ -1,14 +1,12 @@ import uuid -from typing import List - from pydantic import BaseModel from . import to_camel class Split(BaseModel): - inventories: List[uuid.UUID] + inventories: list[uuid.UUID] table_id: uuid.UUID class Config: diff --git a/barker/barker/schemas/table.py b/barker/barker/schemas/table.py index eeaabea..ab48013 100644 --- a/barker/barker/schemas/table.py +++ b/barker/barker/schemas/table.py @@ -1,7 +1,5 @@ import uuid -from typing import Optional - from pydantic import BaseModel, Field from . import to_camel @@ -29,7 +27,7 @@ class Table(TableIn): class TableBlank(TableIn): name: str - section: Optional[SectionLink] + section: SectionLink | None class Config: alias_generator = to_camel @@ -37,7 +35,7 @@ class TableBlank(TableIn): class TableLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] + name: str | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/tax.py b/barker/barker/schemas/tax.py index 518aab1..85043d7 100644 --- a/barker/barker/schemas/tax.py +++ b/barker/barker/schemas/tax.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import Optional from pydantic import BaseModel, Field @@ -36,8 +35,8 @@ class TaxBlank(TaxIn): class TaxLink(BaseModel): id_: uuid.UUID = Field(...) - name: Optional[str] - rate: Optional[Decimal] + name: str | None + rate: Decimal | None class Config: fields = {"id_": "id"} diff --git a/barker/barker/schemas/tax_report.py b/barker/barker/schemas/tax_report.py index 4ae805d..6597619 100644 --- a/barker/barker/schemas/tax_report.py +++ b/barker/barker/schemas/tax_report.py @@ -1,6 +1,5 @@ from datetime import date, datetime from decimal import Decimal -from typing import List from pydantic import BaseModel, validator @@ -21,7 +20,7 @@ class TaxReportItem(BaseModel): class TaxReport(BaseModel): start_date: date finish_date: date - amounts: List[TaxReportItem] + amounts: list[TaxReportItem] class Config: anystr_strip_whitespace = True diff --git a/barker/barker/schemas/update_product_prices.py b/barker/barker/schemas/update_product_prices.py index b8315c1..51dac8a 100644 --- a/barker/barker/schemas/update_product_prices.py +++ b/barker/barker/schemas/update_product_prices.py @@ -2,7 +2,6 @@ import uuid from datetime import date, datetime from decimal import Decimal -from typing import List, Optional from pydantic import BaseModel, validator @@ -21,8 +20,8 @@ class UpdateProductPricesItem(BaseModel): class UpdateProductPrices(BaseModel): date_: date - menu_category_id: Optional[uuid.UUID] - items: List[UpdateProductPricesItem] + menu_category_id: uuid.UUID | None + items: list[UpdateProductPricesItem] class Config: alias_generator = to_camel diff --git a/barker/barker/schemas/user.py b/barker/barker/schemas/user.py index 28afb6d..d30c687 100644 --- a/barker/barker/schemas/user.py +++ b/barker/barker/schemas/user.py @@ -1,7 +1,6 @@ import uuid from datetime import datetime -from typing import List, Optional from barker.schemas import to_camel from barker.schemas.role import RoleItem @@ -12,7 +11,7 @@ class UserIn(BaseModel): name: str password: str locked_out: bool - roles: List[RoleItem] + roles: list[RoleItem] class Config: anystr_strip_whitespace = True @@ -36,8 +35,8 @@ class UserMe(UserIn): class UserLink(BaseModel): - id_: Optional[uuid.UUID] - name: Optional[str] + id_: uuid.UUID | None + name: str | None class Config: fields = {"id_": "id"} @@ -46,9 +45,9 @@ class UserLink(BaseModel): class UserList(BaseModel): id_: uuid.UUID name: str - roles: List[str] + roles: list[str] last_device: str - last_date: Optional[datetime] + last_date: datetime | None class Config: anystr_strip_whitespace = True diff --git a/barker/barker/schemas/user_token.py b/barker/barker/schemas/user_token.py index 481fa0a..8c6d3b2 100644 --- a/barker/barker/schemas/user_token.py +++ b/barker/barker/schemas/user_token.py @@ -1,7 +1,5 @@ import uuid -from typing import List - from pydantic import BaseModel @@ -10,4 +8,4 @@ class UserToken(BaseModel): name: str locked_out: bool = False password: str - permissions: List[str] + permissions: list[str] diff --git a/barker/barker/schemas/voucher.py b/barker/barker/schemas/voucher.py index e6b691f..ecd35c7 100644 --- a/barker/barker/schemas/voucher.py +++ b/barker/barker/schemas/voucher.py @@ -1,7 +1,6 @@ import uuid from decimal import Decimal -from typing import List, Optional from pydantic import BaseModel, Field, validator @@ -14,16 +13,16 @@ from .tax import TaxLink class Inventory(BaseModel): - id_: Optional[uuid.UUID] + id_: uuid.UUID | None product: ProductLink quantity: Decimal = Field(multiple_of=0.01) - price: Optional[Decimal] - tax: Optional[TaxLink] - tax_rate: Optional[Decimal] + price: Decimal | None + tax: TaxLink | None + tax_rate: Decimal | None discount: Decimal = Field(ge=0, multiple_of=0.00001, le=1) is_happy_hour: bool - modifiers: Optional[List[ModifierLink]] - amount: Optional[Decimal] + modifiers: list[ModifierLink] | None + amount: Decimal | None class Config: alias_generator = to_camel @@ -39,8 +38,8 @@ class Inventory(BaseModel): class Kot(BaseModel): - id_: Optional[uuid.UUID] - inventories: List[Inventory] + id_: uuid.UUID | None + inventories: list[Inventory] class Config: anystr_strip_whitespace = True @@ -50,8 +49,8 @@ class Kot(BaseModel): class VoucherIn(BaseModel): pax: int table: TableLink - customer: Optional[CustomerLink] - kots: List[Kot] + customer: CustomerLink | None + kots: list[Kot] class Config: fields = {"id_": "id"} diff --git a/barker/pyproject.toml b/barker/pyproject.toml index 809f8d0..53bb991 100644 --- a/barker/pyproject.toml +++ b/barker/pyproject.toml @@ -5,31 +5,31 @@ description = "Point of Sale for a restaurant" authors = ["tanshu "] [tool.poetry.dependencies] -python = "^3.8" +python = "^3.10" uvicorn = {extras = ["standard"], version = "^0.17.6"} -fastapi = "^0.75.1" +fastapi = "^0.78.0" python-jose = {extras = ["cryptography"], version = "^3.3.0"} passlib = {extras = ["bcrypt"], version = "^1.7.4"} psycopg2-binary = "^2.9.3" -SQLAlchemy = "^1.4.34" +SQLAlchemy = "^1.4.36" python-multipart = "^0.0.5" -PyJWT = "^2.3.0" +PyJWT = "^2.4.0" alembic = "^1.7.7" itsdangerous = "^2.1.2" -python-dotenv = "^0.19.2" -pydantic = {extras = ["dotenv"], version = "^1.9.0"} -starlette = "^0.17.1" -arq = "^0.22" +python-dotenv = "^0.20.0" +pydantic = {extras = ["dotenv"], version = "^1.9.1"} +starlette = "^0.19.1" +arq = "^0.23a1" aiohttp = "^3.8.1" -cryptography = "^36.0.2" +cryptography = "^37.0.2" gunicorn = "^20.1.0" [tool.poetry.dev-dependencies] flake8 = "^4.0.1" black = "^22.3.0" isort = {extras = ["toml"], version = "^5.10.1"} -pre-commit = "^2.17.0" -mypy = "^0.942" +pre-commit = "^2.19.0" +mypy = "^0.950" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/bookie/package.json b/bookie/package.json index 497b123..ec92699 100644 --- a/bookie/package.json +++ b/bookie/package.json @@ -14,51 +14,51 @@ }, "private": true, "dependencies": { - "@angular/animations": "^13.3.1", - "@angular/cdk": "^13.3.2", - "@angular/common": "^13.3.1", - "@angular/compiler": "^13.3.1", - "@angular/core": "^13.3.1", + "@angular/animations": "^13.3.9", + "@angular/cdk": "^13.3.7", + "@angular/common": "^13.3.9", + "@angular/compiler": "^13.3.9", + "@angular/core": "^13.3.9", "@angular/flex-layout": "^13.0.0-beta.38", - "@angular/forms": "^13.3.1", - "@angular/material": "^13.3.2", - "@angular/material-moment-adapter": "^13.3.2", - "@angular/platform-browser": "^13.3.1", - "@angular/platform-browser-dynamic": "^13.3.1", - "@angular/router": "^13.3.1", - "mathjs": "^10.4.2", - "moment": "^2.29.1", + "@angular/forms": "^13.3.9", + "@angular/material": "^13.3.7", + "@angular/material-moment-adapter": "^13.3.7", + "@angular/platform-browser": "^13.3.9", + "@angular/platform-browser-dynamic": "^13.3.9", + "@angular/router": "^13.3.9", + "mathjs": "^10.5.3", + "moment": "^2.29.3", "rxjs": "^6.6.7", "tslib": "^2.2.0", "zone.js": "~0.11.4" }, "devDependencies": { - "@angular-devkit/build-angular": "~13.3.1", - "@angular-eslint/builder": "^13.1.0", - "@angular-eslint/eslint-plugin": "^13.1.0", - "@angular-eslint/eslint-plugin-template": "^13.1.0", - "@angular-eslint/schematics": "^13.1.0", - "@angular-eslint/template-parser": "^13.1.0", - "@angular/cli": "^13.3.1", - "@angular/compiler-cli": "^13.3.1", - "@angular/language-service": "^13.3.1", + "@angular-devkit/build-angular": "~13.3.6", + "@angular-eslint/builder": "^13.2.1", + "@angular-eslint/eslint-plugin": "^13.2.1", + "@angular-eslint/eslint-plugin-template": "^13.2.1", + "@angular-eslint/schematics": "^13.2.1", + "@angular-eslint/template-parser": "^13.2.1", + "@angular/cli": "^13.3.6", + "@angular/compiler-cli": "^13.3.9", + "@angular/language-service": "^13.3.9", "@types/jasmine": "~3.7.4", - "@types/node": "^17.0.23", - "@typescript-eslint/eslint-plugin": "5.17.0", - "@typescript-eslint/parser": "5.17.0", - "eslint": "^8.12.0", - "eslint-plugin-import": "2.25.4", - "husky": "^7.0.4", + "@types/node": "^17.0.35", + "@typescript-eslint/eslint-plugin": "5.25.0", + "@typescript-eslint/parser": "5.25.0", + "eslint": "^8.16.0", + "eslint-plugin-import": "2.26.0", + "husky": "^8.0.1", "jasmine-core": "^3.7.1", "jasmine-spec-reporter": "^7.0.0", "karma": "^6.3.2", - "karma-chrome-launcher": "~3.1.0", + "karma-chrome-launcher": "~3.1.1", "karma-coverage-istanbul-reporter": "~3.0.2", - "karma-jasmine": "^4.0.0", - "karma-jasmine-html-reporter": "^1.6.0", - "lint-staged": "^12.3.7", - "prettier": "^2.6.1", - "standard-version": "^9.3.2", + "karma-jasmine": "^4.0.2", + "karma-jasmine-html-reporter": "^1.7.0", + "lint-staged": "^12.4.1", + "prettier": "^2.6.2", + "standard-version": "^9.5.0", "ts-node": "^9.1.1", "typescript": "~4.5.4" }, diff --git a/frank/pyproject.toml b/frank/pyproject.toml index 990965d..c3e26eb 100644 --- a/frank/pyproject.toml +++ b/frank/pyproject.toml @@ -5,11 +5,10 @@ description = "Point of Sale for a restaurant" authors = ["tanshu "] [tool.poetry.dependencies] -python = "^3.9" -pydantic = {extras = ["dotenv"], version = "^1.9.0"} -arq = "^0.22" +python = "^3.10" +pydantic = {extras = ["dotenv"], version = "^1.9.1"} +arq = "^0.23a1" aiohttp = "^3.8.1" -aioredis = "^1.3.1" [build-system] requires = ["poetry-core>=1.0.0"]