[meld: 1/2] Calling super() whenever possible
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 1/2] Calling super() whenever possible
- Date: Thu, 26 Jul 2018 21:19:22 +0000 (UTC)
commit 3a90da8d433c755f45a2ba095ddd33145f589e21
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Jun 10 12:42:56 2018 +0200
Calling super() whenever possible
meld/build_helpers.py | 2 +-
meld/diffgrid.py | 2 +-
meld/diffmap.py | 2 +-
meld/dirdiff.py | 3 +--
meld/filemerge.py | 4 ++--
meld/matchers/diffutil.py | 2 +-
meld/matchers/merge.py | 7 +++----
meld/matchers/myers.py | 6 +++---
meld/meldapp.py | 4 ++--
meld/meldbuffer.py | 4 ++--
meld/melddoc.py | 2 +-
meld/meldwindow.py | 2 +-
meld/preferences.py | 14 +++++++-------
meld/settings.py | 2 +-
meld/tree.py | 3 +--
meld/ui/filechooser.py | 4 ++--
meld/ui/findbar.py | 4 ++--
meld/ui/listwidget.py | 3 +--
meld/ui/notebook.py | 2 +-
meld/ui/notebooklabel.py | 2 +-
meld/ui/statusbar.py | 2 +-
meld/ui/vcdialogs.py | 2 +-
meld/vcview.py | 2 +-
23 files changed, 38 insertions(+), 42 deletions(-)
---
diff --git a/meld/build_helpers.py b/meld/build_helpers.py
index ed875834..d3ef58a8 100644
--- a/meld/build_helpers.py
+++ b/meld/build_helpers.py
@@ -65,7 +65,7 @@ class MeldDistribution(distutils.dist.Distribution):
def __init__(self, *args, **kwargs):
self.no_update_icon_cache = False
self.no_compile_schemas = False
- distutils.dist.Distribution.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
class build_data(distutils.cmd.Command):
diff --git a/meld/diffgrid.py b/meld/diffgrid.py
index 22c8e560..1d05f8a9 100644
--- a/meld/diffgrid.py
+++ b/meld/diffgrid.py
@@ -22,7 +22,7 @@ class DiffGrid(Gtk.Grid):
__gtype_name__ = "DiffGrid"
def __init__(self):
- Gtk.Grid.__init__(self)
+ super().__init__()
self._in_drag = False
self._drag_pos = -1
self._drag_handle = None
diff --git a/meld/diffmap.py b/meld/diffmap.py
index a1ddd37f..e70f2cad 100644
--- a/meld/diffmap.py
+++ b/meld/diffmap.py
@@ -29,7 +29,7 @@ class DiffMap(Gtk.DrawingArea):
__gtype_name__ = "DiffMap"
def __init__(self):
- Gtk.DrawingArea.__init__(self)
+ super().__init__()
self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
self._last_allocation = None
self._scrolladj = None
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 286171c1..c14e42df 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -206,8 +206,7 @@ COL_EMBLEM, COL_EMBLEM_SECONDARY, COL_SIZE, COL_TIME, COL_PERMS, COL_END = \
class DirDiffTreeStore(tree.DiffTreeStore):
def __init__(self, ntree):
- tree.DiffTreeStore.__init__(
- self, ntree, [str, str, object, object, object])
+ super().__init__(ntree, [str, str, object, object, object])
class CanonicalListing:
diff --git a/meld/filemerge.py b/meld/filemerge.py
index 9f02f4bb..861d9cc8 100644
--- a/meld/filemerge.py
+++ b/meld/filemerge.py
@@ -25,12 +25,12 @@ class FileMerge(FileDiff):
differ = merge.AutoMergeDiffer
def _connect_buffer_handlers(self):
- FileDiff._connect_buffer_handlers(self)
+ super()._connect_buffer_handlers()
self.textview[0].set_editable(0)
self.textview[2].set_editable(0)
def get_comparison(self):
- comp = FileDiff.get_comparison(self)
+ comp = super().get_comparison()
return RecentType.Merge, comp[1]
def _merge_files(self):
diff --git a/meld/matchers/diffutil.py b/meld/matchers/diffutil.py
index 2b20fa84..de5dde06 100644
--- a/meld/matchers/diffutil.py
+++ b/meld/matchers/diffutil.py
@@ -78,7 +78,7 @@ class Differ(GObject.GObject):
def __init__(self):
# Internally, diffs are stored from text1 -> text0 and text1 -> text2.
- GObject.GObject.__init__(self)
+ super().__init__()
self.num_sequences = 0
self.seqlength = [0, 0, 0]
self.diffs = [[], []]
diff --git a/meld/matchers/merge.py b/meld/matchers/merge.py
index 7760fb9f..d456a48e 100644
--- a/meld/matchers/merge.py
+++ b/meld/matchers/merge.py
@@ -23,12 +23,12 @@ class AutoMergeDiffer(diffutil.Differ):
# _matcher = PatienceSequenceMatcher
def __init__(self):
- diffutil.Differ.__init__(self)
+ super().__init__()
self.auto_merge = False
self.unresolved = []
def _auto_merge(self, using, texts):
- for out0, out1 in diffutil.Differ._auto_merge(self, using, texts):
+ for out0, out1 in super()._auto_merge(using, texts):
if self.auto_merge and out0[0] == 'conflict':
# we will try to resolve more complex conflicts automatically
# here... if possible
@@ -195,8 +195,7 @@ class AutoMergeDiffer(diffutil.Differ):
]
self.unresolved[lo:hi] = []
- return diffutil.Differ.change_sequence(
- self, sequence, startidx, sizechange, texts)
+ return super().change_sequence(sequence, startidx, sizechange, texts)
def get_unresolved_count(self):
return len(self.unresolved)
diff --git a/meld/matchers/myers.py b/meld/matchers/myers.py
index a5f06256..b00aa358 100644
--- a/meld/matchers/myers.py
+++ b/meld/matchers/myers.py
@@ -83,7 +83,7 @@ class MyersSequenceMatcher(difflib.SequenceMatcher):
return self.matching_blocks
def get_opcodes(self):
- opcodes = difflib.SequenceMatcher.get_opcodes(self)
+ opcodes = super().get_opcodes()
return [DiffChunk._make(chunk) for chunk in opcodes]
def get_difference_opcodes(self):
@@ -349,13 +349,13 @@ class InlineMyersSequenceMatcher(MyersSequenceMatcher):
class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):
def __init__(self, isjunk=None, a="", b="", syncpoints=None):
- MyersSequenceMatcher.__init__(self, isjunk, a, b)
+ super().__init__(isjunk, a, b)
self.isjunk = isjunk
self.syncpoints = syncpoints
def initialise(self):
if self.syncpoints is None or len(self.syncpoints) == 0:
- for i in MyersSequenceMatcher.initialise(self):
+ for i in super().initialise():
yield i
else:
chunks = []
diff --git a/meld/meldapp.py b/meld/meldapp.py
index 75bcc209..a997c2f7 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -43,7 +43,7 @@ optparse._ = _
class MeldApp(Gtk.Application):
def __init__(self):
- Gtk.Application.__init__(self)
+ super().__init__()
self.set_flags(Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.set_application_id("org.gnome.meld")
GLib.set_application_name("Meld")
@@ -200,7 +200,7 @@ class MeldApp(Gtk.Application):
self.should_exit = False
self.output = io.StringIO()
self.exit_status = 0
- optparse.OptionParser.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
def exit(self, status=0, msg=None):
self.should_exit = True
diff --git a/meld/meldbuffer.py b/meld/meldbuffer.py
index 1f483ccd..35e8f4f9 100644
--- a/meld/meldbuffer.py
+++ b/meld/meldbuffer.py
@@ -37,7 +37,7 @@ class MeldBuffer(GtkSource.Buffer):
)
def __init__(self):
- GtkSource.Buffer.__init__(self)
+ super().__init__()
bind_settings(self)
self.data = MeldBufferData()
self.undo_sequence = None
@@ -98,7 +98,7 @@ class MeldBufferData(GObject.GObject):
)
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
self._gfile = None
self._label = None
self._monitor = None
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 1155f826..5c8d7a72 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -93,7 +93,7 @@ class MeldDoc(LabeledObjectMixin, GObject.GObject):
}
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
self.scheduler = FifoScheduler()
self.num_panes = 0
self.main_actiongroup = None
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index dbfbc096..4d66a281 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -40,7 +40,7 @@ from meld.windowstate import SavedWindowState
class MeldWindow(Component):
def __init__(self):
- Component.__init__(self, "meldapp.ui", "meldapp")
+ super().__init__("meldapp.ui", "meldapp")
self.widget.set_name("meldapp")
actions = (
diff --git a/meld/preferences.py b/meld/preferences.py
index 850f3ee2..d5f5ba80 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -31,8 +31,8 @@ class FilterList(ListWidget):
def __init__(self, key, filter_type):
default_entry = [_("label"), False, _("pattern"), True]
- ListWidget.__init__(
- self, "EditableList.ui", "list_vbox", ["EditableListStore"],
+ super().__init__(
+ "EditableList.ui", "list_vbox", ["EditableListStore"],
"EditableList", default_entry)
self.key = key
self.filter_type = filter_type
@@ -85,8 +85,8 @@ class ColumnList(ListWidget):
}
def __init__(self, key):
- ListWidget.__init__(
- self, "EditableList.ui", "columns_ta", ["ColumnsListStore"],
+ super().__init__(
+ "EditableList.ui", "columns_ta", ["ColumnsListStore"],
"columns_treeview")
self.key = key
@@ -124,7 +124,7 @@ class ColumnList(ListWidget):
class GSettingsComboBox(Gtk.ComboBox):
def __init__(self):
- Gtk.ComboBox.__init__(self)
+ super().__init__()
self.connect('notify::gsettings-value', self._setting_changed)
self.connect('notify::active', self._active_changed)
@@ -182,8 +182,8 @@ class GSettingsStringComboBox(GSettingsComboBox):
class PreferencesDialog(Component):
def __init__(self, parent):
- Component.__init__(
- self, "preferences.ui", "preferencesdialog", [
+ super().__init__(
+ "preferences.ui", "preferencesdialog", [
"adjustment1", "adjustment2", "fileorderstore",
"sizegroup_editor", "timestampstore", "mergeorderstore",
"sizegroup_file_order_labels", "sizegroup_file_order_combos",
diff --git a/meld/settings.py b/meld/settings.py
index d7860cef..3d389b70 100644
--- a/meld/settings.py
+++ b/meld/settings.py
@@ -35,7 +35,7 @@ class MeldSettings(GObject.GObject):
}
def __init__(self):
- GObject.GObject.__init__(self)
+ super().__init__()
self.on_setting_changed(settings, 'filename-filters')
self.on_setting_changed(settings, 'text-filters')
self.on_setting_changed(settings, 'use-system-font')
diff --git a/meld/tree.py b/meld/tree.py
index 8d76c893..36b73e7b 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -18,7 +18,6 @@ import os
from gi.repository import Gdk
from gi.repository import GLib
-from gi.repository import Gtk
from gi.repository import Pango
from meld.misc import colour_lookup_with_fallback
@@ -43,7 +42,7 @@ class DiffTreeStore(SearchableTreeStore):
full_types = []
for col_type in (COL_TYPES + tuple(types)):
full_types.extend([col_type] * ntree)
- Gtk.TreeStore.__init__(self, *full_types)
+ super().__init__(*full_types)
self.ntree = ntree
self._setup_default_styles()
diff --git a/meld/ui/filechooser.py b/meld/ui/filechooser.py
index 861a2b0d..6fcc1501 100644
--- a/meld/ui/filechooser.py
+++ b/meld/ui/filechooser.py
@@ -34,8 +34,8 @@ class MeldFileChooserDialog(Gtk.FileChooserDialog):
def __init__(
self, title=None, transient_for=None,
action=Gtk.FileChooserAction.OPEN):
- Gtk.FileChooserDialog.__init__(
- self, title=title, transient_for=transient_for, action=action)
+ super().__init__(
+ title=title, transient_for=transient_for, action=action)
self.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
if action == Gtk.FileChooserAction.SAVE:
diff --git a/meld/ui/findbar.py b/meld/ui/findbar.py
index aa67c6ad..cf9a606a 100644
--- a/meld/ui/findbar.py
+++ b/meld/ui/findbar.py
@@ -21,8 +21,8 @@ from meld.ui import gnomeglade
class FindBar(gnomeglade.Component):
def __init__(self, parent):
- gnomeglade.Component.__init__(self, "findbar.ui", "findbar",
- ["arrow_left", "arrow_right"])
+ super().__init__("findbar.ui", "findbar",
+ ["arrow_left", "arrow_right"])
self.set_text_view(None)
self.arrow_left.show()
self.arrow_right.show()
diff --git a/meld/ui/listwidget.py b/meld/ui/listwidget.py
index f8f06347..efd3a5c9 100644
--- a/meld/ui/listwidget.py
+++ b/meld/ui/listwidget.py
@@ -20,8 +20,7 @@ from . import gnomeglade
class ListWidget(gnomeglade.Component):
def __init__(self, ui_file, widget, store, treeview, new_row_data=None):
- gnomeglade.Component.__init__(self, ui_file,
- widget, store)
+ super().__init__(ui_file, widget, store)
self.new_row_data = new_row_data
self.list = getattr(self, treeview)
self.model = self.list.get_model()
diff --git a/meld/ui/notebook.py b/meld/ui/notebook.py
index eaa21748..343cbe98 100644
--- a/meld/ui/notebook.py
+++ b/meld/ui/notebook.py
@@ -76,7 +76,7 @@ class MeldNotebook(Gtk.Notebook):
"""
def __init__(self, *args, **kwargs):
- Gtk.Notebook.__init__(self, *args, **kwargs)
+ super().__init__(*args, **kwargs)
self.action_group = Gio.SimpleActionGroup()
diff --git a/meld/ui/notebooklabel.py b/meld/ui/notebooklabel.py
index 9d1099b7..5d36e22f 100644
--- a/meld/ui/notebooklabel.py
+++ b/meld/ui/notebooklabel.py
@@ -28,7 +28,7 @@ class NotebookLabel(Gtk.HBox):
tab_width_in_chars = 30
def __init__(self, iconname, text, onclose):
- Gtk.HBox.__init__(self, homogeneous=False, spacing=4)
+ super().__init__(homogeneous=False, spacing=4)
label = Gtk.Label(label=text)
# FIXME: ideally, we would use custom ellipsization that ellipsized the
diff --git a/meld/ui/statusbar.py b/meld/ui/statusbar.py
index 0cd06d23..fac49aea 100644
--- a/meld/ui/statusbar.py
+++ b/meld/ui/statusbar.py
@@ -69,7 +69,7 @@ class MeldStatusMenuButton(Gtk.MenuButton):
)
def __init__(self):
- Gtk.MenuButton.__init__(self)
+ super().__init__()
style_context = self.get_style_context()
style_context.add_provider(
diff --git a/meld/ui/vcdialogs.py b/meld/ui/vcdialogs.py
index 60499823..74e4edc3 100644
--- a/meld/ui/vcdialogs.py
+++ b/meld/ui/vcdialogs.py
@@ -105,7 +105,7 @@ class CommitDialog(GObject.GObject, Component):
class PushDialog(Component):
def __init__(self, parent):
- Component.__init__(self, "vcview.ui", "pushdialog")
+ super().__init__("vcview.ui", "pushdialog")
self.widget.set_transient_for(parent.widget.get_toplevel())
self.widget.show_all()
diff --git a/meld/vcview.py b/meld/vcview.py
index 68aef804..6e2bd5af 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -113,7 +113,7 @@ COL_LOCATION, COL_STATUS, COL_OPTIONS, COL_END = \
class VcTreeStore(tree.DiffTreeStore):
def __init__(self):
- tree.DiffTreeStore.__init__(self, 1, [str] * 5)
+ super().__init__(1, [str] * 5)
def get_file_path(self, it):
return self.get_value(it, self.column_index(tree.COL_PATH, 0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]