@@ -93,32 +93,6 @@ class NestedConfig:
93
93
"""field"""
94
94
95
95
96
- @config
97
- @dataclass
98
- class FromCliConfig1 :
99
- field : int = 1
100
- """field"""
101
-
102
- @classmethod
103
- def from_cli (cls , cli_value : str ):
104
- inst = cls (** json .loads (cli_value ))
105
- inst .field += 1
106
- return inst
107
-
108
-
109
- @config
110
- @dataclass
111
- class FromCliConfig2 :
112
- field : int = 1
113
- """field"""
114
-
115
- @classmethod
116
- def from_cli (cls , cli_value : str ):
117
- inst = cls (** json .loads (cli_value ))
118
- inst .field += 2
119
- return inst
120
-
121
-
122
96
@config
123
97
@dataclass
124
98
class DummyConfig :
@@ -144,10 +118,6 @@ class DummyConfig:
144
118
"""Dict which will be JSON in CLI"""
145
119
nested_config : NestedConfig = field (default_factory = NestedConfig )
146
120
"""Nested config"""
147
- from_cli_config1 : FromCliConfig1 = field (default_factory = FromCliConfig1 )
148
- """Config with from_cli method"""
149
- from_cli_config2 : FromCliConfig2 = field (default_factory = FromCliConfig2 )
150
- """Different config with from_cli method"""
151
121
152
122
153
123
@pytest .mark .parametrize (("type_hint" , "expected" ), [
@@ -199,9 +169,6 @@ def test_get_kwargs():
199
169
assert json_tip in kwargs ["json_tip" ]["help" ]
200
170
# nested config should should construct the nested config
201
171
assert kwargs ["nested_config" ]["type" ]('{"field": 2}' ) == NestedConfig (2 )
202
- # from_cli configs should be constructed with the correct method
203
- assert kwargs ["from_cli_config1" ]["type" ]('{"field": 2}' ).field == 3
204
- assert kwargs ["from_cli_config2" ]["type" ]('{"field": 2}' ).field == 4
205
172
206
173
207
174
@pytest .mark .parametrize (
0 commit comments