Skip to content

Commit

Permalink
Fixed @with_partial to support missing and empty docstring. Fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain MARIE committed Mar 18, 2019
1 parent ff58d72 commit 18e00d8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions makefun/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,14 @@ def partial_f(*args, **kwargs):
if len(argstring) > 0:
argstring = argstring + ', '
argstring = argstring + ', '.join(["%s=%s" % (k, v) for k, v in preset_kwargs.items()])
new_line = "<This function is equivalent to '%s(%s)', see original '%s' doc below.>\n" \
"" % (partial_f.__name__, argstring, partial_f.__name__)

# new_line = new_line + ("-" * (len(new_line) - 1)) + '\n'
try:
doc = getattr(partial_f, '__doc__')
doc = getattr(partial_f, '__doc__', None)
if doc is None or len(doc) == 0:
partial_f.__doc__ = "<This function is equivalent to '%s(%s)'.>\n" % (partial_f.__name__, argstring)
else:
new_line = "<This function is equivalent to '%s(%s)', see original '%s' doc below.>\n" \
"" % (partial_f.__name__, argstring, partial_f.__name__)
partial_f.__doc__ = new_line + doc
except AttributeError:
partial_f.__doc__ = new_line

return partial_f

0 comments on commit 18e00d8

Please sign in to comment.