diff --git a/dev-requirements.txt b/dev-requirements.txt index 767fe73..269a7e3 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,13 +1,13 @@ # Require a newer fabric than our public API does, since it includes the now # public test helpers. Bleh. -fabric>=2.1.3,<3 +fabric>=3.2,<4 Sphinx>=1.4,<1.7 releases>=1.6,<2.0 alabaster==0.7.12 wheel==0.24 -twine==1.11.0 -invocations>=1.3.0,<2.0 -pytest-relaxed==1.1.4 +twine==5.1.1 +invocations>=3.0,<4.0 +pytest-relaxed==2.0.2 coverage==4.4.2 pytest-cov==2.4.0 mock==1.0.1 diff --git a/patchwork/files.py b/patchwork/files.py index 1e68512..eab10b8 100644 --- a/patchwork/files.py +++ b/patchwork/files.py @@ -4,8 +4,6 @@ import re -from invoke.vendor import six - from .util import set_runner @@ -116,7 +114,7 @@ def append(c, runner, filename, text, partial=False, escape=True): Whether to perform regex-oriented escaping on ``text``. """ # Normalize non-list input to be a list - if isinstance(text, six.string_types): + if isinstance(text, str): text = [text] for line in text: regex = "^" + _escape_for_regex(line) + ("" if partial else "$") diff --git a/patchwork/transfers.py b/patchwork/transfers.py index e7292da..df0540a 100644 --- a/patchwork/transfers.py +++ b/patchwork/transfers.py @@ -2,8 +2,6 @@ File transfer functionality above and beyond basic ``put``/``get``. """ -from invoke.vendor import six - def rsync( c, @@ -79,7 +77,7 @@ def rsync( (rsync's ``--rsh`` flag.) """ # Turn single-string exclude into a one-item list for consistency - if isinstance(exclude, six.string_types): + if isinstance(exclude, str): exclude = [exclude] # Create --exclude options from exclude list exclude_opts = ' --exclude "{}"' * len(exclude) @@ -97,7 +95,7 @@ def rsync( # always-a-list, always-up-to-date-from-all-sources attribute to save us # from having to do this sort of thing. (may want to wait for Paramiko auth # overhaul tho!) - if isinstance(keys, six.string_types): + if isinstance(keys, str): keys = [keys] if keys: key_string = "-i " + " -i ".join(keys) diff --git a/patchwork/util.py b/patchwork/util.py index 705a475..c383a85 100644 --- a/patchwork/util.py +++ b/patchwork/util.py @@ -5,7 +5,7 @@ import textwrap from functools import wraps -from inspect import getargspec, formatargspec +from inspect import signature, Parameter # TODO: calling all functions as eg directory(c, '/foo/bar/') (with initial c) @@ -126,18 +126,21 @@ 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) + params = sig.parameters # Nix positional version of runner arg, which is always 2nd - del args[1] - # Add new args to end in desired order - args.extend(["sudo", "runner_method", "runner"]) - # Add default values (remembering that this tuple matches the _end_ of the - # 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) + params = [p for i, p in enumerate(params.values()) if i != 1] + # Add new args to end in desired order with desired default values + params.extend( + [ + Parameter("sudo", Parameter.POSITIONAL_OR_KEYWORD, default=False), + Parameter("runner_method", Parameter.POSITIONAL_OR_KEYWORD, default="run"), + Parameter("runner", Parameter.POSITIONAL_OR_KEYWORD, default=None), + ] ) + sig = sig.replace(parameters=params) + # Get signature first line for Sphinx autodoc_docstring_signature + sigtext = "{}{}".format(f.__name__, str(sig)) docstring = textwrap.dedent(inner.__doc__ or "").strip() # Construct :param: list params = """:param bool sudo: diff --git a/setup.py b/setup.py index 0e92cb5..c9f877b 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ author="Jeff Forcier", author_email="jeff@bitprophet.org", url="https://fabric-patchwork.readthedocs.io", - install_requires=["fabric>=2.0,<3.0"], + install_requires=["fabric>=3.0,<4.0"], packages=find_packages(), classifiers=[ "Development Status :: 5 - Production/Stable",