Skip to content

Commit c37b268

Browse files
committed
Fix munge_docstring
Signed-off-by: Cristian Le <[email protected]>
1 parent a048604 commit c37b268

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/patchwork/util.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
"""
22
Helpers and decorators, primarily for internal or advanced use.
33
"""
4-
import inspect
54
import textwrap
65

76
from functools import wraps
8-
from inspect import getfullargspec, signature
7+
from inspect import signature, Parameter
98

109

1110
# TODO: calling all functions as eg directory(c, '/foo/bar/') (with initial c)
@@ -127,13 +126,14 @@ def munge_docstring(f, inner):
127126
# (modified) signature; leverages the fact that autodoc_docstring_signature
128127
# is True by default.
129128
sig = signature(f)
130-
args = [p.name for p in sig.parameters.values() if p.POSITIONAL_ONLY]
131-
defaults = [p.default for p in sig.parameters.values() if p.default is not p.empty]
129+
parameters = list(sig.parameters.values())
132130
# Nix positional version of runner arg, which is always 2nd
133-
args.extend(["sudo", "runner_method", "runner"])
134-
# Add default values (remembering that this tuple matches the _end_ of the
135-
# signature...)
136-
defaults = tuple(list(defaults or []) + [False, "run", None])
131+
del parameters[1]
132+
# Append new arguments
133+
parameters.append(Parameter("sudo", Parameter.POSITIONAL_OR_KEYWORD, default=False))
134+
parameters.append(Parameter("runner_method", Parameter.POSITIONAL_OR_KEYWORD, default="run"))
135+
parameters.append(Parameter("runner", Parameter.POSITIONAL_OR_KEYWORD, default=None))
136+
sig = sig.replace(parameters=parameters)
137137
# Get signature first line for Sphinx autodoc_docstring_signature
138138
docstring = textwrap.dedent(inner.__doc__ or "").strip()
139139
# Construct :param: list
@@ -144,4 +144,4 @@ def munge_docstring(f, inner):
144144
:param runner:
145145
Callable runner function or method. Should ideally be a bound method on the given context object!
146146
""" # noqa
147-
return f"{sig}\n{docstring}\n\n{params}"
147+
return f"{f.__name__}{sig}\n{docstring}\n\n{params}"

0 commit comments

Comments
 (0)