switch to pydantic

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2023-11-28 23:50:50 -08:00
parent d9d73522fd
commit bc3d698539
230 changed files with 4467 additions and 25280 deletions

View File

@ -1,72 +1,12 @@
from typing import Any, Dict, List, Type, TypeVar, Union
import attr
from pydantic import BaseModel
from ..models.unit_angle import UnitAngle
from ..types import UNSET, Unset
UZ = TypeVar("UZ", bound="Angle")
@attr.s(auto_attribs=True)
class Angle:
"""An angle, with a specific unit.""" # noqa: E501
class Angle(BaseModel):
"""An angle, with a specific unit."""
unit: Union[Unset, UnitAngle] = UNSET
value: Union[Unset, float] = UNSET
unit: UnitAngle
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
unit: Union[Unset, UnitAngle] = UNSET
if not isinstance(self.unit, Unset):
unit = self.unit
value = self.value
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if unit is not UNSET:
field_dict["unit"] = unit
if value is not UNSET:
field_dict["value"] = value
return field_dict
@classmethod
def from_dict(cls: Type[UZ], src_dict: Dict[str, Any]) -> UZ:
d = src_dict.copy()
_unit = d.pop("unit", UNSET)
unit: Union[Unset, UnitAngle]
if isinstance(_unit, Unset):
unit = UNSET
if _unit is None:
unit = UNSET
else:
unit = _unit
value = d.pop("value", UNSET)
angle = cls(
unit=unit,
value=value,
)
angle.additional_properties = d
return angle
@property
def additional_keys(self) -> List[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties
value: float