-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolis_join_config.py
More file actions
40 lines (29 loc) · 932 Bytes
/
solis_join_config.py
File metadata and controls
40 lines (29 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import Any, Dict, Literal, Type, TypeVar, cast
from attrs import define as _attrs_define
T = TypeVar("T", bound="SolisJoinConfig")
@_attrs_define
class SolisJoinConfig:
"""
Attributes:
vendor (Literal['solis']): Default: 'solis'.
"""
vendor: Literal["solis"] = "solis"
def to_dict(self) -> Dict[str, Any]:
vendor = self.vendor
field_dict: Dict[str, Any] = {}
field_dict.update(
{
"vendor": vendor,
}
)
return field_dict
@classmethod
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
d = src_dict.copy()
vendor = cast(Literal["solis"], d.pop("vendor"))
if vendor != "solis":
raise ValueError(f"vendor must match const 'solis', got '{vendor}'")
solis_join_config = cls(
vendor=vendor,
)
return solis_join_config