- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython_di.py
More file actions
Latest commit
56 lines (40 loc) · 1.06 KB
/
Copy pathpython_di.py
File metadata and controls
56 lines (40 loc) · 1.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
importtypes
importyaml
data="""
params:
a: 1
b: 2
O33:
class: O1
p1: 2
p2: 3
O2:
p1: 2
p2: 3
instantiate: O33, O2
"""
classAllStatic(type):
def__new__(mcls, name, base, dct):
ndct= {}
forname, vindct.items():
ifisinstance(v, types.FunctionType):
v=staticmethod(v)
ndct[name] =v
returnsuper().__new__(mcls, name, bases, ndct)
classDI(metaclass=AllStatic):
defparam1(a: int, b: int) ->str:
returnf"{a}::{b}"
defempty_objs(all_objs: List[IObject1]) ->List[IObject1]:
returnall_objs[:2]
classO1(IObject1):
def__init__(self, p1: int, p2: int, param1: str):
pass
classO2(IObject2):
def__init__(self, p1: int, p2: int, empty_objs: List[IObject1]):
pass
defcreate_system(instantiate: List[str],
config_params: Dict[str, Dict[str, Any]],
extra_params: Dict[str, Any],
lazy_params: Any,
classes: Dict[str, type]) ->Dict[str, Any]:
pass