Skip to content

Commit

Permalink
Preserve metadata when using autocurry as a decorator (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Apr 12, 2022
1 parent 4ea62a4 commit 60910f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion funcy/funcs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from operator import __not__
from functools import partial, reduce
from functools import partial, reduce, wraps

from .compat import map
from ._inspect import get_spec, Spec
Expand Down Expand Up @@ -70,6 +70,7 @@ def autocurry(func, n=EMPTY, _spec=None, _args=(), _kwargs={}):
until sufficient arguments are passed."""
spec = _spec or (get_spec(func) if n is EMPTY else Spec(n, set(), n, set(), False))

@wraps(func)
def autocurried(*a, **kw):
args = _args + a
kwargs = _kwargs.copy()
Expand Down
9 changes: 9 additions & 0 deletions tests/test_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ class B: pass
class I(int): pass
assert autocurry(int)(base=12)('100') == 144

def test_autocurry_docstring():

@autocurry
def f(a, b):
'docstring'

assert f.__doc__ == 'docstring'



def test_compose():
double = _ * 2
Expand Down

0 comments on commit 60910f8

Please sign in to comment.