We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5bc133a commit 727d123Copy full SHA for 727d123
src/oqd_dataschema/datastore.py
@@ -18,7 +18,7 @@
18
19
import json
20
import pathlib
21
-from typing import Any, Dict, Literal
+from typing import Any, Callable, Dict, Literal
22
23
import h5py
24
from pydantic import (
@@ -220,8 +220,16 @@ def add(self, **groups):
220
221
self.update(**groups)
222
223
- def pipe(self, func) -> Datastore:
224
- return func(self)
+ def pipe(self, func: Callable[[Datastore], Datastore]) -> Datastore:
+ _result = func(self)
225
+
226
+ if _result is None:
227
+ return self
228
229
+ if _result is not Datastore:
230
+ raise ValueError("`func` must return None or Datastore.")
231
232
+ return _result
233
234
235
# %%
0 commit comments