From 762f66b146b676aaa3b7f1dfcc3d65118976822f Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Wed, 7 Jul 2021 15:39:32 +0000 Subject: [PATCH] Add missing calls to super class "__init__"s (#1693) * FIX : Add missing call to __init__ in super class * FIX : Add missing call to __init__ in super class * FIX : Add missing call to __init__ in super class * FIX : Add missing call to super __init__ and fix a flake8 error modified: traitsui/editors/array_editor.py modified: traitsui/qt4/ui_panel.py * DEV : Undo change in qt4 GroupEditor see #1674 modified: traitsui/qt4/ui_panel.py * CLN : Pass args to __init__ call Previously, we were setting traits/attributes before calling __init__ on the objects, which setup the traits machinery. Instead, this commit passes the arguments to __init__, which feels like the right thing to do modified: traitsui/editors/array_editor.py modified: traitsui/editors/tuple_editor.py modified: traitsui/qt4/ui_panel.py --- traitsui/editors/array_editor.py | 3 +-- traitsui/editors/tuple_editor.py | 5 ++--- traitsui/qt4/ui_panel.py | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/traitsui/editors/array_editor.py b/traitsui/editors/array_editor.py index e1f12a854..bb9f6235d 100644 --- a/traitsui/editors/array_editor.py +++ b/traitsui/editors/array_editor.py @@ -55,8 +55,7 @@ class ArrayStructure(HasTraits): def __init__(self, editor): """ Initializes the object. """ - # Save the reference to the editor: - self.editor = editor + super().__init__(editor=editor) # Set up the field width for each item: width = editor.factory.width diff --git a/traitsui/editors/tuple_editor.py b/traitsui/editors/tuple_editor.py index 862ce95ac..a07d2d86a 100644 --- a/traitsui/editors/tuple_editor.py +++ b/traitsui/editors/tuple_editor.py @@ -113,15 +113,14 @@ class TupleStructure(HasTraits): def __init__(self, editor): """ Initializes the object. """ + super().__init__(editor=editor) + factory = editor.factory types = factory.types labels = factory.labels editors = factory.editors cols = factory.cols - # Save the reference to the editor: - self.editor = editor - # Get the tuple we are mirroring: object = editor.value diff --git a/traitsui/qt4/ui_panel.py b/traitsui/qt4/ui_panel.py index f49203979..011f05ab2 100644 --- a/traitsui/qt4/ui_panel.py +++ b/traitsui/qt4/ui_panel.py @@ -102,7 +102,8 @@ class _Panel(BasePanel): def __init__(self, ui, parent, is_subpanel): """Initialise the object. """ - self.ui = ui + super().__init__(ui=ui) + history = ui.history view = ui.view