From 108a6a0a29cf89e3736cbebba57c9fd2d6f4ad91 Mon Sep 17 00:00:00 2001 From: DeviousStoat Date: Fri, 19 Jan 2024 05:39:52 +0100 Subject: [PATCH] Add for curry --- src/pydash/functions.py | 5 +++++ tests/test_functions.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/pydash/functions.py b/src/pydash/functions.py index dc1b08a..cf43fee 100644 --- a/src/pydash/functions.py +++ b/src/pydash/functions.py @@ -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: diff --git a/tests/test_functions.py b/tests/test_functions.py index 5979f62..73c03aa 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -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