remove pydantic from customer_attributes.py

This commit is contained in:
2025-03-09 09:18:15 -05:00
parent c365fd7a7f
commit 237d294b25

View File

@@ -1,22 +1,25 @@
from dataclasses import dataclass, field
from typing import ClassVar from typing import ClassVar
from pydantic import BaseModel, model_validator
from src.models import KeypadSize from src.models import KeypadSize
from src.utils import generate_random_nonrepeating_list from src.utils import generate_random_nonrepeating_list
class CustomerAttributes(BaseModel): @dataclass
class CustomerAttributes:
attr_vals: list[int] attr_vals: list[int]
set_vals: list[int] set_vals: list[int]
keypad_size: KeypadSize keypad_size: KeypadSize
MAX_KEYS: ClassVar[int] = 256 MAX_KEYS: ClassVar[int] = 256
MAX_ATTRS_PER_KEY: ClassVar[int] = 256 MAX_ATTRS_PER_KEY: ClassVar[int] = 256
@model_validator(mode='after') def __post_init__(self):
def check_keys_vs_attrs(self) -> 'CustomerAttributes': self.check_keys_vs_attrs()
def check_keys_vs_attrs(self) -> None:
if self.keypad_size.is_dispersable: if self.keypad_size.is_dispersable:
raise ValueError("number of keys must be less than the number of " raise ValueError("number of keys must be less than the number of "
"attributes per key to be dispersion resistant") "attributes per key to be dispersion resistant")
return self
@classmethod @classmethod
def create(cls, keypad_size: KeypadSize) -> 'CustomerAttributes': def create(cls, keypad_size: KeypadSize) -> 'CustomerAttributes':