-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython_di.py
More file actions
56 lines (40 loc) · 1.06 KB
/
python_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
import types
import yaml
data = """
params:
a: 1
b: 2
O33:
class: O1
p1: 2
p2: 3
O2:
p1: 2
p2: 3
instantiate: O33, O2
"""
class AllStatic(type):
def __new__(mcls, name, base, dct):
ndct = {}
for name, v in dct.items():
if isinstance(v, types.FunctionType):
v = staticmethod(v)
ndct[name] = v
return super().__new__(mcls, name, bases, ndct)
class DI(metaclass=AllStatic):
def param1(a: int, b: int) -> str:
return f"{a}::{b}"
def empty_objs(all_objs: List[IObject1]) -> List[IObject1]:
return all_objs[:2]
class O1(IObject1):
def __init__(self, p1: int, p2: int, param1: str):
pass
class O2(IObject2):
def __init__(self, p1: int, p2: int, empty_objs: List[IObject1]):
pass
def create_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