From bc98cc1875156eeee842f9c651b81a163b2c11dd Mon Sep 17 00:00:00 2001 From: Angelos Evripiotis Date: Tue, 11 Jun 2019 17:28:17 +0100 Subject: Refactor 'super(cls, self)' -> 'super()' For most use-cases with modern Python, it's not necessary to supply the 'type' or 'object-or-type' arguments to super(). Replace all our instances with arg-less super, which is less error-prone. https://docs.python.org/3.5/library/functions.html#super --- src/buildstream/_frontend/widget.py | 14 +++++++------- src/buildstream/_fuse/fuse.py | 2 +- src/buildstream/_options/optionarch.py | 2 +- src/buildstream/_options/optionbool.py | 2 +- src/buildstream/_options/optioneltmask.py | 2 +- src/buildstream/_options/optionenum.py | 2 +- src/buildstream/_options/optionflags.py | 2 +- src/buildstream/_options/optionos.py | 2 +- src/buildstream/_yaml.pyx | 2 +- tests/testutils/repo/bzr.py | 2 +- tests/testutils/repo/git.py | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py index cfe3a06e9..cdef589b7 100644 --- a/src/buildstream/_frontend/widget.py +++ b/src/buildstream/_frontend/widget.py @@ -85,7 +85,7 @@ class Space(Widget): class FixedText(Widget): def __init__(self, context, text, content_profile, format_profile): - super(FixedText, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) self.text = text def render(self, message): @@ -96,7 +96,7 @@ class FixedText(Widget): class WallclockTime(Widget): def __init__(self, context, content_profile, format_profile, output_format=False): self._output_format = output_format - super(WallclockTime, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) def render(self, message): @@ -132,7 +132,7 @@ class Debug(Widget): class TimeCode(Widget): def __init__(self, context, content_profile, format_profile, microseconds=False): self._microseconds = microseconds - super(TimeCode, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) def render(self, message): return self.render_time(message.elapsed) @@ -216,7 +216,7 @@ class MessageText(Widget): class CacheKey(Widget): def __init__(self, context, content_profile, format_profile, err_profile): - super(CacheKey, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) self._err_profile = err_profile self._key_length = context.log_key_length @@ -248,7 +248,7 @@ class CacheKey(Widget): class LogFile(Widget): def __init__(self, context, content_profile, format_profile, err_profile): - super(LogFile, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) self._err_profile = err_profile self._logdir = context.logdir @@ -278,7 +278,7 @@ class LogFile(Widget): # class MessageOrLogFile(Widget): def __init__(self, context, content_profile, format_profile, err_profile): - super(MessageOrLogFile, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) self._message_widget = MessageText(context, content_profile, format_profile) self._logfile_widget = LogFile(context, content_profile, format_profile, err_profile) @@ -314,7 +314,7 @@ class LogLine(Widget): err_profile, detail_profile, indent=4): - super(LogLine, self).__init__(context, content_profile, format_profile) + super().__init__(context, content_profile, format_profile) self._columns = [] self._failure_messages = defaultdict(list) diff --git a/src/buildstream/_fuse/fuse.py b/src/buildstream/_fuse/fuse.py index 4ff6b9903..5c97cc466 100644 --- a/src/buildstream/_fuse/fuse.py +++ b/src/buildstream/_fuse/fuse.py @@ -426,7 +426,7 @@ def fuse_get_context(): class FuseOSError(OSError): def __init__(self, errno): - super(FuseOSError, self).__init__(errno, strerror(errno)) + super().__init__(errno, strerror(errno)) class FUSE(object): diff --git a/src/buildstream/_options/optionarch.py b/src/buildstream/_options/optionarch.py index 0e2963c84..3117b8273 100644 --- a/src/buildstream/_options/optionarch.py +++ b/src/buildstream/_options/optionarch.py @@ -40,7 +40,7 @@ class OptionArch(OptionEnum): OPTION_TYPE = 'arch' def load(self, node): - super(OptionArch, self).load(node, allow_default_definition=False) + super().load(node, allow_default_definition=False) def load_default_value(self, node): arch = Platform.get_host_arch() diff --git a/src/buildstream/_options/optionbool.py b/src/buildstream/_options/optionbool.py index 867de22df..bdbb1d32a 100644 --- a/src/buildstream/_options/optionbool.py +++ b/src/buildstream/_options/optionbool.py @@ -32,7 +32,7 @@ class OptionBool(Option): def load(self, node): - super(OptionBool, self).load(node) + super().load(node) _yaml.node_validate(node, OPTION_SYMBOLS + ['default']) self.value = _yaml.node_get(node, bool, 'default') diff --git a/src/buildstream/_options/optioneltmask.py b/src/buildstream/_options/optioneltmask.py index 09c2ce8c2..507dc7070 100644 --- a/src/buildstream/_options/optioneltmask.py +++ b/src/buildstream/_options/optioneltmask.py @@ -33,7 +33,7 @@ class OptionEltMask(OptionFlags): def load(self, node): # Ask the parent constructor to disallow value definitions, # we define those automatically only. - super(OptionEltMask, self).load(node, allow_value_definitions=False) + super().load(node, allow_value_definitions=False) # Here we want all valid elements as possible values, # but we'll settle for just the relative filenames diff --git a/src/buildstream/_options/optionenum.py b/src/buildstream/_options/optionenum.py index 095b9c356..f214d779d 100644 --- a/src/buildstream/_options/optionenum.py +++ b/src/buildstream/_options/optionenum.py @@ -31,7 +31,7 @@ class OptionEnum(Option): OPTION_TYPE = 'enum' def load(self, node, allow_default_definition=True): - super(OptionEnum, self).load(node) + super().load(node) valid_symbols = OPTION_SYMBOLS + ['values'] if allow_default_definition: diff --git a/src/buildstream/_options/optionflags.py b/src/buildstream/_options/optionflags.py index 0271208d9..ba16244ba 100644 --- a/src/buildstream/_options/optionflags.py +++ b/src/buildstream/_options/optionflags.py @@ -31,7 +31,7 @@ class OptionFlags(Option): OPTION_TYPE = 'flags' def load(self, node, allow_value_definitions=True): - super(OptionFlags, self).load(node) + super().load(node) valid_symbols = OPTION_SYMBOLS + ['default'] if allow_value_definitions: diff --git a/src/buildstream/_options/optionos.py b/src/buildstream/_options/optionos.py index 2d46b70ba..6263a05a2 100644 --- a/src/buildstream/_options/optionos.py +++ b/src/buildstream/_options/optionos.py @@ -29,7 +29,7 @@ class OptionOS(OptionEnum): OPTION_TYPE = 'os' def load(self, node): - super(OptionOS, self).load(node, allow_default_definition=False) + super().load(node, allow_default_definition=False) def load_default_value(self, node): return platform.uname().system diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx index 2122dea3a..678374272 100644 --- a/src/buildstream/_yaml.pyx +++ b/src/buildstream/_yaml.pyx @@ -147,7 +147,7 @@ cdef class ProvenanceInformation: # public exceptions.py class CompositeError(Exception): def __init__(self, path, message): - super(CompositeError, self).__init__(message) + super().__init__(message) self.path = path self.message = message diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py index 8b2f17844..5b64ba042 100644 --- a/tests/testutils/repo/bzr.py +++ b/tests/testutils/repo/bzr.py @@ -11,7 +11,7 @@ class Bzr(Repo): def __init__(self, directory, subdir): if not HAVE_BZR: pytest.skip("bzr is not available") - super(Bzr, self).__init__(directory, subdir) + super().__init__(directory, subdir) self.bzr = BZR def create(self, directory): diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index f4e300b53..0ed0590be 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -16,7 +16,7 @@ class Git(Repo): self.submodules = {} - super(Git, self).__init__(directory, subdir) + super().__init__(directory, subdir) def _run_git(self, *args, **kwargs): argv = [GIT] -- cgit v1.2.1