Skip to content

Commit

Permalink
Add for curry
Browse files Browse the repository at this point in the history
  • Loading branch information
DeviousStoat committed Jan 19, 2024
1 parent eef539a commit 108a6a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pydash/functions.py
Expand Up @@ -242,6 +242,11 @@ def compose_args(self, new_args):
"""Combine `self.args` with `new_args` and return."""
return tuple(list(self.args) + list(new_args))

@property
def _argcount(self) -> t.Optional[int]:
argcount = self.arity - len(self.args) - len(self.kwargs)
return argcount if argcount >= 0 else None


class CurryOne(Curry[T1, T]):
def __call__(self, arg_one: T1) -> T:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_functions.py
Expand Up @@ -410,6 +410,14 @@ def test_partial_right_argcount():
assert _.partial_right(lambda x, y, z: x + y + z, 1, 2)._argcount == 1


def test_curry_argcount():
assert _.curry(lambda x, y, z: x + y + z)(1)._argcount == 2


def test_curry_right_argcount():
assert _.curry_right(lambda x, y, z: x + y + z)(1)._argcount == 2


def test_can_be_used_as_predicate_argcount_is_known():
def is_positive(x: int) -> bool:
return x > 0
Expand Down

0 comments on commit 108a6a0

Please sign in to comment.