From 7e953127360dd519faef16102f2fc5c99fd17f84 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Thu, 29 Jun 2023 10:01:27 +0200 Subject: [PATCH] Remove recursive parsing for lists (#33) * fixes #29: removed recursive parsing for lists * Un-xfail test for ints as strings --------- Co-authored-by: Luigi Privitera <36084390+Luigi-98@users.noreply.github.com> --- confection/__init__.py | 2 -- confection/tests/test_config.py | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/confection/__init__.py b/confection/__init__.py index 758c4f8..9b49ff5 100644 --- a/confection/__init__.py +++ b/confection/__init__.py @@ -273,8 +273,6 @@ def _interpret_value(self, value: Any) -> Any: # NOTE: This currently can't handle uninterpolated values like [${x.y}]! if isinstance(result, str) and VARIABLE_RE.search(value): result = value - if isinstance(result, list): - return [self._interpret_value(v) for v in result] return result def _get_section_ref(self, value: Any, *, parent: List[str] = []) -> Any: diff --git a/confection/tests/test_config.py b/confection/tests/test_config.py index 8ec9f0f..b0020b8 100644 --- a/confection/tests/test_config.py +++ b/confection/tests/test_config.py @@ -1398,9 +1398,8 @@ def test_warn_single_quotes(): cfg = Config().from_str(str_cfg) -@pytest.mark.xfail def test_parse_strings_interpretable_as_ints(): """Test whether strings interpretable as integers are parsed correctly (i. e. as strings).""" cfg = Config().from_str(f"""[a]\nfoo = [${{b.bar}}, "00${{b.bar}}", "y"]\n\n[b]\nbar = 3""") assert cfg["a"]["foo"] == [3, "003", "y"] - assert cfg["b"]["bar"] == 3 \ No newline at end of file + assert cfg["b"]["bar"] == 3