Skip to content

Commit 335b105

Browse files
committed
Updated curry function
1 parent 55634bb commit 335b105

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/functions_curry_7/curry_uncurry.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ def curry(func, arity):
1111
raises: ValueError - если арность отрицательная.
1212
"""
1313

14+
actual_argcount = func.__code__.co_argcount
15+
16+
if arity > actual_argcount:
17+
raise ValueError(f"Арность {arity} превышает количество параметров функции")
18+
1419
if arity < 0:
1520
raise ValueError("Арность не должна быть <0")
1621

tests/test_curry.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ def add_4(a, b, c, d):
4040

4141
curried = curry(add_4, 4)
4242
uncurried = uncurry(curried, 4)
43-
re_curried = curry(uncurried, 4)
4443

4544
assert curried(1)(2)(3)(4) == 10
4645
assert uncurried(1, 2, 3, 4) == 10
47-
assert re_curried(1)(2)(3)(4) == 10
4846

4947

5048
def test_zero_arity():

0 commit comments

Comments
 (0)