Skip to content

Commit

Permalink
Correctly handle parameters with empty lists as values
Browse files Browse the repository at this point in the history
  • Loading branch information
GDYendell committed Aug 20, 2024
1 parent c213f25 commit ebd0dde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/odin_fastcs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ def _walk_odin_metadata(
for node_name, node_value in tree.items():
node_path = path + [node_name]

# Trees - dict or list[dict] to recurse through
if isinstance(node_value, dict) and not is_metadata_object(node_value):
yield from _walk_odin_metadata(node_value, node_path)
elif isinstance(node_value, list) and all(
isinstance(m, dict) for m in node_value
elif (
isinstance(node_value, list)
and node_value # Exclude parameters with an empty list as a value
and all(isinstance(m, dict) for m in node_value)
):
for idx, sub_node in enumerate(node_value):
sub_node_path = node_path + [str(idx)]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def test_one_node():
response = json.loads(f.read())

parameters = create_odin_parameters(response)
assert len(parameters) == 96
assert len(parameters) == 97


def test_two_node():
with (HERE / "input/two_node_fp_response.json").open() as f:
response = json.loads(f.read())

parameters = create_odin_parameters(response)
assert len(parameters) == 188
assert len(parameters) == 190


@pytest.mark.asyncio
Expand Down

0 comments on commit ebd0dde

Please sign in to comment.