Skip to content

workaround to get utils.exists working #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion patchwork/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import re

from invoke.vendor import six
import six

from .util import set_runner

Expand Down
19 changes: 14 additions & 5 deletions patchwork/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import textwrap

from functools import wraps
from inspect import getargspec, formatargspec
#from inspect import getargspec, formatargspec
from inspect import signature, Parameter


# TODO: calling all functions as eg directory(c, '/foo/bar/') (with initial c)
Expand Down Expand Up @@ -126,7 +127,13 @@ def munge_docstring(f, inner):
# Terrible, awful hacks to ensure Sphinx autodoc sees the intended
# (modified) signature; leverages the fact that autodoc_docstring_signature
# is True by default.
args, varargs, keywords, defaults = getargspec(f)
sig = signature(f)
args = [param.name for param in sig.parameters.values() if param.kind in (Parameter.POSITIONAL_OR_KEYWORD, Parameter.POSITIONAL_ONLY)]
varargs = next((param.name for param in sig.parameters.values() if param.kind == Parameter.VAR_POSITIONAL), None)
keywords = next((param.name for param in sig.parameters.values() if param.kind == Parameter.VAR_KEYWORD), None)
defaults = [param.default for param in sig.parameters.values() if param.default is not Parameter.empty]

#args, varargs, keywords, defaults = getargspec(f)
# Nix positional version of runner arg, which is always 2nd
del args[1]
# Add new args to end in desired order
Expand All @@ -135,9 +142,11 @@ def munge_docstring(f, inner):
# signature...)
defaults = tuple(list(defaults or []) + [False, "run", None])
# Get signature first line for Sphinx autodoc_docstring_signature
sigtext = "{}{}".format(
f.__name__, formatargspec(args, varargs, keywords, defaults)
)
# sigtext = "{}{}".format(
# f.__name__, formatargspec(args, varargs, keywords, defaults)
# )
sigtext = "{}{}".format(f.__name__, signature(f))

docstring = textwrap.dedent(inner.__doc__ or "").strip()
# Construct :param: list
params = """:param bool sudo:
Expand Down