Skip to content

Commit

Permalink
Remove recursive parsing for lists (#33)
Browse files Browse the repository at this point in the history
* fixes #29: removed recursive parsing for lists

* Un-xfail test for ints as strings

---------

Co-authored-by: Luigi Privitera <[email protected]>
  • Loading branch information
adrianeboyd and Luigi-98 authored Jun 29, 2023
1 parent 958bc25 commit 7e95312
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 0 additions & 2 deletions confection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions confection/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
assert cfg["b"]["bar"] == 3

0 comments on commit 7e95312

Please sign in to comment.