Skip to content

Commit

Permalink
refactor: remove additional python2 cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
kuwv committed Jan 15, 2023
1 parent 5231ce9 commit 3a209e0
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion invoke/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .tasks import Task


class Collection(object):
class Collection:
"""
A collection of executable tasks. See :doc:`/concepts/namespaces`.
Expand Down
4 changes: 2 additions & 2 deletions invoke/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def load_source(name, path):
return vars(SourceFileLoader("mod", path).load_module())


class DataProxy(object):
class DataProxy:
"""
Helper class implementing nested dict+attr access for `.Config`.
Expand Down Expand Up @@ -122,7 +122,7 @@ def __setattr__(self, key, value):
# to our internal dict/cache
self[key] = value
else:
super(DataProxy, self).__setattr__(key, value)
super().__setattr__(key, value)

def __iter__(self):
# For some reason Python is ignoring our __hasattr__ when determining
Expand Down
2 changes: 1 addition & 1 deletion invoke/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def __init__(self, config=None, **kwargs):
Changed ``repeat`` default value from ``False`` to ``True``.
"""
# Set up like any other Context would, with the config
super(MockContext, self).__init__(config)
super().__init__(config)
# Pull out behavioral kwargs
self._set("__repeat", kwargs.pop("repeat", True))
# The rest must be things like run/sudo - mock Context method info
Expand Down
2 changes: 1 addition & 1 deletion invoke/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .util import debug


class Environment(object):
class Environment:
def __init__(self, config, prefix):
self._config = config
self._prefix = prefix
Expand Down
6 changes: 3 additions & 3 deletions invoke/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __str__(self):

def _repr(self, **kwargs):
kwargs.setdefault("exited", self.result.exited)
return super(UnexpectedExit, self)._repr(**kwargs)
return super()._repr(**kwargs)


class CommandTimedOut(Failure):
Expand All @@ -138,7 +138,7 @@ class CommandTimedOut(Failure):
"""

def __init__(self, result, timeout):
super(CommandTimedOut, self).__init__(result)
super().__init__(result)
self.timeout = timeout

def __repr__(self):
Expand Down Expand Up @@ -190,7 +190,7 @@ class ParseError(Exception):
"""

def __init__(self, msg, context=None):
super(ParseError, self).__init__(msg)
super().__init__(msg)
self.context = context


Expand Down
2 changes: 1 addition & 1 deletion invoke/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .tasks import Call, Task


class Executor(object):
class Executor:
"""
An execution strategy for Task objects.
Expand Down
4 changes: 2 additions & 2 deletions invoke/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .util import debug


class Loader(object):
class Loader:
"""
Abstract class defining how to find/import a session's base `.Collection`.
Expand Down Expand Up @@ -100,7 +100,7 @@ class FilesystemLoader(Loader):
# as auto-dashes, and has to grow one of those for every bit Collection
# ever needs to know
def __init__(self, start=None, **kwargs):
super(FilesystemLoader, self).__init__(**kwargs)
super().__init__(**kwargs)
if start is None:
start = self.config.tasks.search_root
self._start = start
Expand Down
2 changes: 1 addition & 1 deletion invoke/parser/argument.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Argument(object):
class Argument:
"""
A command-line argument/flag.
Expand Down
2 changes: 1 addition & 1 deletion invoke/parser/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def flag_key(x):

# Named slightly more verbose so Sphinx references can be unambiguous.
# Got real sick of fully qualified paths.
class ParserContext(object):
class ParserContext:
"""
Parsing context with knowledge of flags & their format.
Expand Down
6 changes: 3 additions & 3 deletions invoke/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def is_long_flag(value):
return value.startswith("--")


class Parser(object):
class Parser:
"""
Create parser conscious of ``contexts`` and optional ``initial`` context.
Expand Down Expand Up @@ -206,7 +206,7 @@ def __init__(self, initial, contexts, ignore_unknown):
self.contexts = copy.deepcopy(contexts)
debug("Available contexts: {!r}".format(self.contexts))
# In case StateMachine does anything in __init__
super(ParseMachine, self).__init__()
super().__init__()

@property
def waiting_for_flag_value(self):
Expand Down Expand Up @@ -431,6 +431,6 @@ class ParseResult(list):
"""

def __init__(self, *args, **kwargs):
super(ParseResult, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.remainder = ""
self.unparsed = []
2 changes: 1 addition & 1 deletion invoke/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .util import debug, enable_logging, helpline


class Program(object):
class Program:
"""
Manages top-level CLI invocation, typically via ``setup.py`` entrypoints.
Expand Down
6 changes: 3 additions & 3 deletions invoke/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from .util import has_fileno, isatty, ExceptionHandlingThread


class Runner(object):
class Runner:
"""
Partially-abstract core command-running API.
Expand Down Expand Up @@ -1181,7 +1181,7 @@ class Local(Runner):
"""

def __init__(self, context):
super(Local, self).__init__(context)
super().__init__(context)
# Bookkeeping var for pty use case
self.status = None

Expand Down Expand Up @@ -1340,7 +1340,7 @@ def stop(self):
pass


class Result(object):
class Result:
"""
A container for information about the result of a command execution.
Expand Down
4 changes: 2 additions & 2 deletions invoke/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .parser import Argument, translate_underscores


class Task(object):
class Task:
"""
Core object representing an executable task & its argument specification.
Expand Down Expand Up @@ -358,7 +358,7 @@ def inner(obj):
return inner


class Call(object):
class Call:
"""
Represents a call/execution of a `.Task` with given (kw)args.
Expand Down
4 changes: 2 additions & 2 deletions invoke/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(self, **kwargs):
``**kwargs`` for easier display of thread identity when raising
captured exceptions.
"""
super(ExceptionHandlingThread, self).__init__(**kwargs)
super().__init__(**kwargs)
# No record of why, but Fabric used daemon threads ever since the
# switch from select.select, so let's keep doing that.
self.daemon = True
Expand Down Expand Up @@ -200,7 +200,7 @@ def run(self):
# worker body, orthogonal to how exception handling works
self._run()
else:
super(ExceptionHandlingThread, self).run()
super().run()
except BaseException:
# Store for actual reraising later
self.exc_info = sys.exc_info()
Expand Down
4 changes: 2 additions & 2 deletions invoke/watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ class FailingResponder(Responder):
"""

def __init__(self, pattern, response, sentinel):
super(FailingResponder, self).__init__(pattern, response)
super().__init__(pattern, response)
self.sentinel = sentinel
self.failure_index = 0
self.tried = False

def submit(self, stream):
# Behave like regular Responder initially
response = super(FailingResponder, self).submit(stream)
response = super().submit(stream)
# Also check stream for our failure sentinel
failed = self.pattern_matches(stream, self.sentinel, "failure_index")
# Error out if we seem to have failed after a previous response.
Expand Down

0 comments on commit 3a209e0

Please sign in to comment.