Skip to content

Commit 5ecd82f

Browse files
committed
Refactor error handling in BaseConfig and simplify test parameters in MemoryConfig tests
1 parent e554cf7 commit 5ecd82f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

config/config/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def get(self, key: str, /, default: Any = None, set_if_not_found: bool = False)
6060
ref_key = match.group(1)
6161
ref_value = self.get(ref_key)
6262
config = config.replace(match.group(0), str(ref_value))
63-
elif not isinstance(config, (int, float, bool)):
64-
raise KeyError(f"The provided key '{key}' is not a valid endpoint for a configuration value.")
63+
# elif not isinstance(config, (int, float, bool)):
64+
# raise KeyError(f"The provided key '{key}' is not a valid endpoint for a configuration value.")
6565
_trace(f"Config value for key '{key}': {config}")
6666
return config
6767

config/tests/memory_tests.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,13 @@ def test_get_edge_cases(initial, key, default, set_if_not_found, expected):
6767

6868

6969
@pytest.mark.parametrize(
70-
"initial, key, test_id",
70+
"initial, key",
7171
[
72-
({}, "foo", "get_missing_no_default"),
73-
({"foo": {"bar": {}}}, "foo.bar", "get_nonendpoint_dict_no_default"),
72+
({}, "foo"),
7473
],
75-
ids=lambda p: p if isinstance(p, str) else None
74+
ids=["get_missing_no_default"]
7675
)
77-
def test_get_errors(initial, key, test_id):
76+
def test_get_errors(initial, key):
7877
# Arrange
7978

8079
config = MemoryConfig(initial)
@@ -188,4 +187,4 @@ def test_set_reference():
188187
assert config.get("bar") == 42
189188
assert config.get("baz.qux") == "42"
190189
assert config.get("test") == "69"
191-
assert config.get("complex") == "69.01"
190+
assert config.get("complex") == "69.01"

0 commit comments

Comments
 (0)