diff --git a/snakebids/core/datasets.py b/snakebids/core/datasets.py index 361e4998..33e84506 100644 --- a/snakebids/core/datasets.py +++ b/snakebids/core/datasets.py @@ -394,17 +394,20 @@ def sequencify(item: bool | str | Iterable[str]) -> bool | list[str]: return list(itx.always_iterable(item)) allow_missing_seq = sequencify(allow_missing) - inner_expand = list( - # order preserving deduplication - dict.fromkeys( - sn_expand( - list(itx.always_iterable(paths)), - zip, - allow_missing=True if wildcards else allow_missing_seq, - **self.zip_lists, + if self.zip_lists: + inner_expand = list( + # order preserving deduplication + dict.fromkeys( + sn_expand( + list(itx.always_iterable(paths)), + zip, + allow_missing=True if wildcards else allow_missing_seq, + **self.zip_lists, + ) ) ) - ) + else: + inner_expand = list(itx.always_iterable(paths)) if not wildcards: return inner_expand diff --git a/snakebids/tests/test_datasets.py b/snakebids/tests/test_datasets.py index 89dd8378..2be0fd10 100644 --- a/snakebids/tests/test_datasets.py +++ b/snakebids/tests/test_datasets.py @@ -340,6 +340,16 @@ def test_expand_preserves_entry_order(self, component: Expandable): for path, entity_vals in zip(paths, zip(*component.zip_lists.values())): assert bids(**dict(zip(component.zip_lists.keys(), entity_vals))) == path + @given(path=st.text()) + def test_expandable_with_no_wildcards_returns_path_unaltered(self, path: str): + component = BidsPartialComponent(zip_lists={}) + assert itx.one(component.expand(path)) == path + + @given(component=sb_st.expandables(min_values=0, max_values=0, path_safe=True)) + def test_expandable_with_no_entries_returns_empty_list(self, component: Expandable): + path_tpl = bids(**get_wildcard_dict(component.zip_lists)) + assert component.expand(path_tpl) == [] + class TestBidsComponentExpand: """