Skip to content

Commit e3edc0a

Browse files
authored
Extract CompilationConfig from config.py (#22524)
Signed-off-by: Harry Mellor <[email protected]>
1 parent baece8c commit e3edc0a

File tree

5 files changed

+467
-480
lines changed

5 files changed

+467
-480
lines changed

tests/engine/test_arg_utils.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,6 @@ class NestedConfig:
9393
"""field"""
9494

9595

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-
12296
@config
12397
@dataclass
12498
class DummyConfig:
@@ -144,10 +118,6 @@ class DummyConfig:
144118
"""Dict which will be JSON in CLI"""
145119
nested_config: NestedConfig = field(default_factory=NestedConfig)
146120
"""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"""
151121

152122

153123
@pytest.mark.parametrize(("type_hint", "expected"), [
@@ -199,9 +169,6 @@ def test_get_kwargs():
199169
assert json_tip in kwargs["json_tip"]["help"]
200170
# nested config should should construct the nested config
201171
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
205172

206173

207174
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)