4 from typing
import List
6 from dataclasses
import dataclass, field
8 @dataclass(frozen=
True)
10 """Class to hold chain properties with (limited) type-checking"""
13 monGroups: List[str] =
field(default_factory = list)
14 l1SeedThresholds: List[str] =
field(default_factory = list)
15 stream: List[str] =
field(default_factory =
lambda : [
'Main'])
16 mergingStrategy: str =
'auto'
17 mergingOrder: List[str] =
field(default_factory = list)
18 mergingOffset: int = -1
19 topoStartFrom: bool =
False
24 """Check field types"""
25 for f
in dataclasses.fields(self):
26 actual_type = typing.get_origin(f.type)
or f.type
27 value = getattr(self, f.name)
28 if actual_type == list:
31 if not isinstance(el, typing.get_args(f.type)):
33 elif not isinstance(value, actual_type):
40 raise TypeError(f
"Expected type of '{f.name}' to be {f.type}, "
41 f
"got {repr(getattr(self, f.name))}")
43 if __name__==
'__main__':