tool_state_pending.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from collections.abc import Mapping
  2. from typing import Any, Literal, TypeVar, cast
  3. from attrs import define as _attrs_define
  4. from attrs import field as _attrs_field
  5. T = TypeVar("T", bound="ToolStatePending")
  6. @_attrs_define
  7. class ToolStatePending:
  8. """
  9. Attributes:
  10. status (Literal['pending']):
  11. """
  12. status: Literal["pending"]
  13. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  14. def to_dict(self) -> dict[str, Any]:
  15. status = self.status
  16. field_dict: dict[str, Any] = {}
  17. field_dict.update(self.additional_properties)
  18. field_dict.update(
  19. {
  20. "status": status,
  21. }
  22. )
  23. return field_dict
  24. @classmethod
  25. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  26. d = dict(src_dict)
  27. status = cast(Literal["pending"], d.pop("status"))
  28. if status != "pending":
  29. raise ValueError(f"status must match const 'pending', got '{status}'")
  30. tool_state_pending = cls(
  31. status=status,
  32. )
  33. tool_state_pending.additional_properties = d
  34. return tool_state_pending
  35. @property
  36. def additional_keys(self) -> list[str]:
  37. return list(self.additional_properties.keys())
  38. def __getitem__(self, key: str) -> Any:
  39. return self.additional_properties[key]
  40. def __setitem__(self, key: str, value: Any) -> None:
  41. self.additional_properties[key] = value
  42. def __delitem__(self, key: str) -> None:
  43. del self.additional_properties[key]
  44. def __contains__(self, key: str) -> bool:
  45. return key in self.additional_properties