From 50293b994ea889dc53fc48a5201e399e9700b4c5 Mon Sep 17 00:00:00 2001 From: Peter Grayson Date: Mon, 1 Feb 2021 08:58:36 -0500 Subject: [PATCH] Use super() where applicable Use modern form of super() as a better way to call superclass methods. Signed-off-by: Peter Grayson --- stgit/argparse.py | 4 ++-- stgit/lib/git/date.py | 2 +- stgit/lib/git/iw.py | 2 +- stgit/lib/git/repository.py | 2 +- stgit/lib/stack.py | 8 ++++---- stgit/lib/transaction.py | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/stgit/argparse.py b/stgit/argparse.py index 815750a..90fc273 100644 --- a/stgit/argparse.py +++ b/stgit/argparse.py @@ -371,9 +371,9 @@ def merged_option(): class strings(list): def __init__(self, *args): - super(strings, self).__init__(args) + super().__init__(args) class patch_range(list): def __init__(self, *args): - super(patch_range, self).__init__(args) + super().__init__(args) diff --git a/stgit/lib/git/date.py b/stgit/lib/git/date.py index eeb9e05..cd2f819 100644 --- a/stgit/lib/git/date.py +++ b/stgit/lib/git/date.py @@ -11,7 +11,7 @@ class DateException(StgException): """Exception raised when a date+time string could not be parsed.""" def __init__(self, string, type): - StgException.__init__(self, '"%s" is not a valid %s' % (string, type)) + super().__init__('"%s" is not a valid %s' % (string, type)) class TimeZone(tzinfo): diff --git a/stgit/lib/git/iw.py b/stgit/lib/git/iw.py index c3184c2..6359ca7 100644 --- a/stgit/lib/git/iw.py +++ b/stgit/lib/git/iw.py @@ -15,7 +15,7 @@ class MergeConflictException(MergeException): """Exception raised when a merge fails due to conflicts.""" def __init__(self, conflicts): - MergeException.__init__(self) + super().__init__() self.conflicts = conflicts diff --git a/stgit/lib/git/repository.py b/stgit/lib/git/repository.py index e55e739..7e7d13a 100644 --- a/stgit/lib/git/repository.py +++ b/stgit/lib/git/repository.py @@ -24,7 +24,7 @@ class DetachedHeadException(RepositoryException): current branch).""" def __init__(self): - RepositoryException.__init__(self, 'Not on any branch') + super().__init__('Not on any branch') class Refs: diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py index 7f5f9a1..8cf8386 100644 --- a/stgit/lib/stack.py +++ b/stgit/lib/stack.py @@ -265,7 +265,7 @@ class Stack(Branch): _repo_subdir = 'patches' def __init__(self, repository, name): - Branch.__init__(self, repository, name) + super().__init__(repository, name) self.patchorder = PatchOrder(self) self.patches = Patches(self) if not stackupgrade.update_to_current_format_version(repository, name): @@ -339,7 +339,7 @@ class Stack(Branch): def rename(self, new_name): old_name = self.name patch_names = self.patchorder.all - super(Stack, self).rename(new_name) + super().rename(new_name) renames = [] for pn in patch_names: renames.append((_patch_ref(old_name, pn), _patch_ref(new_name, pn))) @@ -485,8 +485,8 @@ class StackRepository(Repository): """A git L{Repository} with some added StGit-specific operations.""" - def __init__(self, *args, **kwargs): - Repository.__init__(self, *args, **kwargs) + def __init__(self, directory): + super().__init__(directory) self._stacks = {} # name -> Stack @property diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py index 1998890..21bd1a4 100644 --- a/stgit/lib/transaction.py +++ b/stgit/lib/transaction.py @@ -43,12 +43,12 @@ class _TransPatchMap(dict): """Maps patch names to Commit objects.""" def __init__(self, stack): - dict.__init__(self) + super().__init__() self._stack = stack def __getitem__(self, pn): try: - return dict.__getitem__(self, pn) + return super().__getitem__(pn) except KeyError: return self._stack.patches.get(pn).commit -- 2.11.4.GIT