|
| 1 | +from typing import Any, Dict, List, Type, TypeVar |
| 2 | + |
| 3 | +import attr |
| 4 | + |
| 5 | +T = TypeVar("T", bound="ModelReferenceWithPeriods") |
| 6 | + |
| 7 | + |
| 8 | +@attr.s(auto_attribs=True) |
| 9 | +class ModelReferenceWithPeriods: |
| 10 | + """A Model with periods in its reference""" |
| 11 | + |
| 12 | + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) |
| 13 | + |
| 14 | + def to_dict(self) -> Dict[str, Any]: |
| 15 | + |
| 16 | + field_dict: Dict[str, Any] = {} |
| 17 | + field_dict.update(self.additional_properties) |
| 18 | + field_dict.update({}) |
| 19 | + |
| 20 | + return field_dict |
| 21 | + |
| 22 | + @classmethod |
| 23 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 24 | + d = src_dict.copy() |
| 25 | + model_reference_with_periods = cls() |
| 26 | + |
| 27 | + model_reference_with_periods.additional_properties = d |
| 28 | + return model_reference_with_periods |
| 29 | + |
| 30 | + @property |
| 31 | + def additional_keys(self) -> List[str]: |
| 32 | + return list(self.additional_properties.keys()) |
| 33 | + |
| 34 | + def __getitem__(self, key: str) -> Any: |
| 35 | + return self.additional_properties[key] |
| 36 | + |
| 37 | + def __setitem__(self, key: str, value: Any) -> None: |
| 38 | + self.additional_properties[key] = value |
| 39 | + |
| 40 | + def __delitem__(self, key: str) -> None: |
| 41 | + del self.additional_properties[key] |
| 42 | + |
| 43 | + def __contains__(self, key: str) -> bool: |
| 44 | + return key in self.additional_properties |
0 commit comments