Skip to content

Commit

Permalink
simplify verb / builtin verb decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-rudolph committed Sep 26, 2024
1 parent d93bf90 commit 1f1afc6
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/pydiverse/transform/pipe/pipeable.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,22 @@ def __call__(self, /, *args, **keywords):
return self.func(*args, *self.args, **keywords)


def verb(func):
@wraps(func)
def wrapper(*args, **kwargs):
def f(*args, **kwargs):
return func(*args, **kwargs)
# TODO: validate that the first arg is a table here


f = inverse_partial(f, *args, **kwargs) # Bind arguments
return Pipeable(f)
def verb(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
return Pipeable(inverse_partial(fn, *args, **kwargs))

return wrapper


def builtin_verb(backends=None):
def decorator(func):
@wraps(func)
def decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
f = func
f = inverse_partial(f, *args, **kwargs) # Bind arguments
return Pipeable(f) # Make pipeable
return Pipeable(inverse_partial(fn, *args, **kwargs))

return wrapper

Expand Down

0 comments on commit 1f1afc6

Please sign in to comment.