From b451cd4a37c73c7ad71be9dc3f9fd125f9b9bf40 Mon Sep 17 00:00:00 2001 From: Sai Rahul Poruri Date: Wed, 26 Aug 2020 08:45:07 +0100 Subject: [PATCH] CLN : Update super usage done using automated regex-based search and replace --- envisage/application.py | 2 +- envisage/extension_point.py | 2 +- envisage/extension_point_binding.py | 2 +- envisage/extension_point_changed_event.py | 2 +- envisage/plugin.py | 4 ++-- envisage/plugin_manager.py | 2 +- envisage/plugins/ipython_kernel/heartbeat.py | 2 +- envisage/plugins/ipython_kernel/kernelapp.py | 6 +++--- .../ipython_kernel/tests/test_ipython_kernel_plugin.py | 4 ++-- envisage/plugins/python_shell/view/python_shell_view.py | 2 +- envisage/service.py | 2 +- envisage/ui/action/menu.py | 4 ++-- envisage/ui/action/tool_bar.py | 4 ++-- envisage/ui/single_project/action/save_as_project_action.py | 2 +- envisage/ui/single_project/action/save_project_action.py | 2 +- envisage/ui/single_project/editor/project_editor.py | 4 ++-- envisage/ui/single_project/model_service.py | 2 +- envisage/ui/single_project/project.py | 6 +++--- envisage/ui/single_project/project_action.py | 2 +- envisage/ui/single_project/project_plugin.py | 2 +- envisage/ui/single_project/ui_service.py | 2 +- envisage/ui/single_project/view/project_view.py | 2 +- envisage/ui/tasks/action/preferences_action.py | 2 +- envisage/ui/tasks/action/task_window_toggle_group.py | 2 +- envisage/ui/tasks/preferences_dialog.py | 2 +- envisage/ui/tasks/preferences_pane.py | 2 +- examples/plugins/single_project/sample_project/data/data.py | 6 +++--- .../sample_project/data/plugin/action/data_plugin_action.py | 2 +- .../single_project/sample_project/data/plugin/ui_service.py | 2 +- .../sample_project/plugins/single_project/env_project.py | 4 ++-- examples/plugins/tasks/ipython_kernel/python_editor.py | 4 ++-- 31 files changed, 44 insertions(+), 44 deletions(-) diff --git a/envisage/application.py b/envisage/application.py index ae2bff8ad..b22d76e00 100644 --- a/envisage/application.py +++ b/envisage/application.py @@ -122,7 +122,7 @@ def __init__(self, plugins=None, **traits): """ - super(Application, self).__init__(**traits) + super().__init__(**traits) # fixme: We have to initialize the application home here (i.e. we can't # wait until the 'home' trait is accessed) because the scoped diff --git a/envisage/extension_point.py b/envisage/extension_point.py index 07d049240..8869be5a0 100644 --- a/envisage/extension_point.py +++ b/envisage/extension_point.py @@ -121,7 +121,7 @@ def __init__(self, trait_type=List, id=None, **metadata): # point traits easier to find with the 'traits' and 'trait_names' # methods on 'HasTraits'. metadata["__extension_point__"] = True - super(ExtensionPoint, self).__init__(**metadata) + super().__init__(**metadata) # The trait type that describes the extension point. # diff --git a/envisage/extension_point_binding.py b/envisage/extension_point_binding.py index e9584644f..3edb94ba9 100644 --- a/envisage/extension_point_binding.py +++ b/envisage/extension_point_binding.py @@ -57,7 +57,7 @@ class ExtensionPointBinding(HasTraits): def __init__(self, **traits): """ Constructor. """ - super(ExtensionPointBinding, self).__init__(**traits) + super().__init__(**traits) # Initialize the object's trait from the extension point. self._set_trait(notify=False) diff --git a/envisage/extension_point_changed_event.py b/envisage/extension_point_changed_event.py index d01ef3409..1d5634fb3 100644 --- a/envisage/extension_point_changed_event.py +++ b/envisage/extension_point_changed_event.py @@ -21,7 +21,7 @@ def __init__(self, extension_point_id=None, **kw): """ Constructor. """ # The base class has the 'index', 'removed' and 'added' attributes. - super(ExtensionPointChangedEvent, self).__init__(**kw) + super().__init__(**kw) # We add the extension point Id. self.extension_point_id = extension_point_id diff --git a/envisage/plugin.py b/envisage/plugin.py index eda978d04..4108c495d 100644 --- a/envisage/plugin.py +++ b/envisage/plugin.py @@ -206,7 +206,7 @@ def start(self): """ Start the plugin. This method will *always* be empty so that you never have to call - 'super(xxx, self).start()' if you provide an implementation in a + 'super().start()' if you provide an implementation in a derived class. The framework does what it needs to do when it starts a plugin by means @@ -220,7 +220,7 @@ def stop(self): """ Stop the plugin. This method will *always* be empty so that you never have to call - 'super(xxx, self).stop()' if you provide an implementation in a + 'super().stop()' if you provide an implementation in a derived class. The framework does what it needs to do when it stops a plugin by means diff --git a/envisage/plugin_manager.py b/envisage/plugin_manager.py index f6f1d9dd5..cf1bbea1e 100644 --- a/envisage/plugin_manager.py +++ b/envisage/plugin_manager.py @@ -89,7 +89,7 @@ def __init__(self, plugins=None, **traits): """ - super(PluginManager, self).__init__(**traits) + super().__init__(**traits) if plugins is not None: self._plugins = plugins diff --git a/envisage/plugins/ipython_kernel/heartbeat.py b/envisage/plugins/ipython_kernel/heartbeat.py index 46944164b..2050507e2 100644 --- a/envisage/plugins/ipython_kernel/heartbeat.py +++ b/envisage/plugins/ipython_kernel/heartbeat.py @@ -42,7 +42,7 @@ class Heartbeat(ipykernel.heartbeat.Heartbeat): def run(self): try: - super(Heartbeat, self).run() + super().run() except zmq.ZMQError as e: # We expect to get here on normal context termination, but # not otherwise; re-raise if the error is not the expected one diff --git a/envisage/plugins/ipython_kernel/kernelapp.py b/envisage/plugins/ipython_kernel/kernelapp.py index 10a65a9fd..5b4c776bf 100644 --- a/envisage/plugins/ipython_kernel/kernelapp.py +++ b/envisage/plugins/ipython_kernel/kernelapp.py @@ -139,7 +139,7 @@ def init_crash_handler(self): can be restored later. """ self._original_sys_excepthook = sys.excepthook - super(IPKernelApp, self).init_crash_handler() + super().init_crash_handler() def init_io(self): """ @@ -155,7 +155,7 @@ def init_io(self): if self.displayhook_class: self._original_sys_displayhook = sys.displayhook - super(IPKernelApp, self).init_io() + super().init_io() def init_kernel(self): """ @@ -170,7 +170,7 @@ def init_kernel(self): self._original_ipython_utils_io_stderr = getattr( IPython.utils.io, "stderr", _MISSING ) - super(IPKernelApp, self).init_kernel() + super().init_kernel() # New methods, mostly to control shutdown ################################# diff --git a/envisage/plugins/ipython_kernel/tests/test_ipython_kernel_plugin.py b/envisage/plugins/ipython_kernel/tests/test_ipython_kernel_plugin.py index 360272e50..721cea013 100644 --- a/envisage/plugins/ipython_kernel/tests/test_ipython_kernel_plugin.py +++ b/envisage/plugins/ipython_kernel/tests/test_ipython_kernel_plugin.py @@ -115,7 +115,7 @@ def test_service_not_used(self): class TrackingInternalIPKernel(internal_ipkernel.InternalIPKernel): def __init__(self, *args, **kwargs): - super(TrackingInternalIPKernel, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) kernel_instances.append(self) patcher = mock.patch.object( @@ -142,7 +142,7 @@ def test_service_used(self): class TrackingInternalIPKernel(internal_ipkernel.InternalIPKernel): def __init__(self, *args, **kwargs): - super(TrackingInternalIPKernel, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) kernel_instances.append(self) patcher = mock.patch.object( diff --git a/envisage/plugins/python_shell/view/python_shell_view.py b/envisage/plugins/python_shell/view/python_shell_view.py index d3333efbb..b50408212 100644 --- a/envisage/plugins/python_shell/view/python_shell_view.py +++ b/envisage/plugins/python_shell/view/python_shell_view.py @@ -143,7 +143,7 @@ def destroy_control(self): """ - super(PythonShellView, self).destroy_control() + super().destroy_control() # Unregister the view as a service. self.window.application.unregister_service(self._service_id) diff --git a/envisage/service.py b/envisage/service.py index 159c54f81..cb33e53e6 100644 --- a/envisage/service.py +++ b/envisage/service.py @@ -38,7 +38,7 @@ def __init__( ): """ Constructor. """ - super(Service, self).__init__(**metadata) + super().__init__(**metadata) # The protocol that the service must provide. self._protocol = protocol diff --git a/envisage/ui/action/menu.py b/envisage/ui/action/menu.py index dbd006892..71cee2ad1 100644 --- a/envisage/ui/action/menu.py +++ b/envisage/ui/action/menu.py @@ -32,7 +32,7 @@ class CGroup(Instance): def __init__(self, **kw): """ Constructor. """ - super(CGroup, self).__init__(klass=Group, **kw) + super().__init__(klass=Group, **kw) return @@ -46,7 +46,7 @@ def validate(self, object, name, value): if isinstance(value, str): value = Group(id=value) - return super(CGroup, self).validate(object, name, value) + return super().validate(object, name, value) class Menu(Location): diff --git a/envisage/ui/action/tool_bar.py b/envisage/ui/action/tool_bar.py index ce7755c08..e4c8c3501 100644 --- a/envisage/ui/action/tool_bar.py +++ b/envisage/ui/action/tool_bar.py @@ -33,7 +33,7 @@ class CGroup(Instance): def __init__(self, **kw): """ Constructor. """ - super(CGroup, self).__init__(klass=Group, **kw) + super().__init__(klass=Group, **kw) return @@ -47,7 +47,7 @@ def validate(self, object, name, value): if isinstance(value, str): value = Group(id=value) - return super(CGroup, self).validate(object, name, value) + return super().validate(object, name, value) class ToolBar(Location): diff --git a/envisage/ui/single_project/action/save_as_project_action.py b/envisage/ui/single_project/action/save_as_project_action.py index 8ff0aeba5..97058ecab 100644 --- a/envisage/ui/single_project/action/save_as_project_action.py +++ b/envisage/ui/single_project/action/save_as_project_action.py @@ -74,7 +74,7 @@ def _on_project_changed(self, obj, trait_name, old, new): if new is not None: self._update_project_listeners(new, remove=False) - super(SaveAsAction, self)._on_project_changed( + super()._on_project_changed( obj, trait_name, old, new ) diff --git a/envisage/ui/single_project/action/save_project_action.py b/envisage/ui/single_project/action/save_project_action.py index 9fdcbe02a..1f540d044 100644 --- a/envisage/ui/single_project/action/save_project_action.py +++ b/envisage/ui/single_project/action/save_project_action.py @@ -71,7 +71,7 @@ def _on_project_changed(self, obj, trait_name, old, new): if new is not None: self._update_project_listeners(new, remove=False) - super(SaveAction, self)._on_project_changed(obj, trait_name, old, new) + super()._on_project_changed(obj, trait_name, old, new) ########################################################################## # 'SaveAction' interface diff --git a/envisage/ui/single_project/editor/project_editor.py b/envisage/ui/single_project/editor/project_editor.py index f930c1d0e..423cab51a 100644 --- a/envisage/ui/single_project/editor/project_editor.py +++ b/envisage/ui/single_project/editor/project_editor.py @@ -56,7 +56,7 @@ def __init__(self, **traits): """ - super(ProjectEditor, self).__init__(**traits) + super().__init__(**traits) # Make sure the current project knows this editor is associated with # it's resources @@ -88,6 +88,6 @@ def destroy_control(self): # Unregister from the associated project immediately. self.project.register_editor(self.resource, self, remove=True) - super(ProjectEditor, self).destroy_control() + super().destroy_control() return diff --git a/envisage/ui/single_project/model_service.py b/envisage/ui/single_project/model_service.py index 4a8f2ca35..384634515 100644 --- a/envisage/ui/single_project/model_service.py +++ b/envisage/ui/single_project/model_service.py @@ -72,7 +72,7 @@ def __init__(self, application, factory, **traits): """ - super(ModelService, self).__init__( + super().__init__( application=application, factory=factory, **traits ) diff --git a/envisage/ui/single_project/project.py b/envisage/ui/single_project/project.py index aacc451ff..5e70cdd0c 100644 --- a/envisage/ui/single_project/project.py +++ b/envisage/ui/single_project/project.py @@ -145,7 +145,7 @@ def __getstate__(self): """ # Determine the starting point for our state. - state = super(Project, self).__getstate__().copy() + state = super().__getstate__().copy() # Remove any transient traits. for trait_name in self.trait_names(transient=True): @@ -187,7 +187,7 @@ def __setstate__(self, state): state.pop(key, None) # Restore our state. - return super(Project, self).__setstate__(state) + return super().__setstate__(state) def __str__(self): """ @@ -195,7 +195,7 @@ def __str__(self): """ - result = "%s(name=%s)" % (super(Project, self).__str__(), self.name) + result = "%s(name=%s)" % (super().__str__(), self.name) return result ########################################################################## diff --git a/envisage/ui/single_project/project_action.py b/envisage/ui/single_project/project_action.py index ed3fc600a..c717b2a08 100644 --- a/envisage/ui/single_project/project_action.py +++ b/envisage/ui/single_project/project_action.py @@ -92,7 +92,7 @@ def __init__(self, *args, **kws): self._update_model_service_listeners(remove=False) """ - super(ProjectAction, self).__init__(*args, **kws) + super().__init__(*args, **kws) return diff --git a/envisage/ui/single_project/project_plugin.py b/envisage/ui/single_project/project_plugin.py index 2114a3752..e6106afe9 100644 --- a/envisage/ui/single_project/project_plugin.py +++ b/envisage/ui/single_project/project_plugin.py @@ -228,7 +228,7 @@ def start(self): """ - super(ProjectPlugin, self).start() + super().start() # FIXME: We eventually won't have to explicitly register the # services ourselves, since we contribute them as service offers diff --git a/envisage/ui/single_project/ui_service.py b/envisage/ui/single_project/ui_service.py index a4b7c02be..38680c828 100644 --- a/envisage/ui/single_project/ui_service.py +++ b/envisage/ui/single_project/ui_service.py @@ -91,7 +91,7 @@ def __init__(self, model_service, menu_manager, **traits): """ - super(UiService, self).__init__( + super().__init__( model_service=model_service, default_context_menu_manager=menu_manager, **traits, diff --git a/envisage/ui/single_project/view/project_view.py b/envisage/ui/single_project/view/project_view.py index 20b383778..c9c0f8040 100644 --- a/envisage/ui/single_project/view/project_view.py +++ b/envisage/ui/single_project/view/project_view.py @@ -139,7 +139,7 @@ class ProjectView(HasTraits): # 'View' interface. ########################################################################## def __init__(self, **traits): - super(ProjectView, self).__init__(**traits) + super().__init__(**traits) # Make sure our view stays in sync with the current project model_service = self._get_model_service() diff --git a/envisage/ui/tasks/action/preferences_action.py b/envisage/ui/tasks/action/preferences_action.py index 61bc6f816..a5568c819 100644 --- a/envisage/ui/tasks/action/preferences_action.py +++ b/envisage/ui/tasks/action/preferences_action.py @@ -55,4 +55,4 @@ class PreferencesGroup(Group): ########################################################################### def __init__(self, **traits): - super(PreferencesGroup, self).__init__(PreferencesAction(), **traits) + super().__init__(PreferencesAction(), **traits) diff --git a/envisage/ui/tasks/action/task_window_toggle_group.py b/envisage/ui/tasks/action/task_window_toggle_group.py index a0c339e84..a0a78eb0f 100644 --- a/envisage/ui/tasks/action/task_window_toggle_group.py +++ b/envisage/ui/tasks/action/task_window_toggle_group.py @@ -78,7 +78,7 @@ class TaskWindowToggleGroup(Group): def destroy(self): """ Called when the group is no longer required. """ - super(TaskWindowToggleGroup, self).destroy() + super().destroy() if self.application: self.application.on_trait_change( self._rebuild, "window_opened, window_closed", remove=True diff --git a/envisage/ui/tasks/preferences_dialog.py b/envisage/ui/tasks/preferences_dialog.py index 4f8372b79..7ece80769 100644 --- a/envisage/ui/tasks/preferences_dialog.py +++ b/envisage/ui/tasks/preferences_dialog.py @@ -125,7 +125,7 @@ def close(self, info, is_ok): """ if is_ok: self.apply() - return super(PreferencesDialog, self).close(info, is_ok) + return super().close(info, is_ok) ########################################################################### # Protected interface. diff --git a/envisage/ui/tasks/preferences_pane.py b/envisage/ui/tasks/preferences_pane.py index 4ae9f2cf3..a91f7a093 100644 --- a/envisage/ui/tasks/preferences_pane.py +++ b/envisage/ui/tasks/preferences_pane.py @@ -84,4 +84,4 @@ def close(self, info, is_ok): """ if is_ok: self.apply() - return super(PreferencesPane, self).close(info, is_ok) + return super().close(info, is_ok) diff --git a/examples/plugins/single_project/sample_project/data/data.py b/examples/plugins/single_project/sample_project/data/data.py index b3dc446a2..977781026 100644 --- a/examples/plugins/single_project/sample_project/data/data.py +++ b/examples/plugins/single_project/sample_project/data/data.py @@ -93,7 +93,7 @@ class Data(NumericContext): """ Contains all of the data for a data """ def __init__(self, name="Unknown", **traits): - super(Data, self).__init__(**traits) + super().__init__(**traits) self.context_name = name self.data_parameters = DataView() # self.data_parameters = DataView() @@ -109,7 +109,7 @@ def __getstate__(self): """ # Obtain state from base class(es) - state = super(Data, self).__getstate__() + state = super().__getstate__() # Add in our current version number. Note use a different attribute # name from any base or derived class so that our numbers don't @@ -145,7 +145,7 @@ def __setstate__(self, state): ) # Restore the base class's state. - super(Data, self).__setstate__(state) + super().__setstate__(state) return diff --git a/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.py b/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.py index 1d2f05110..72526874a 100644 --- a/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.py +++ b/examples/plugins/single_project/sample_project/data/plugin/action/data_plugin_action.py @@ -61,7 +61,7 @@ def __init__(self, **kws): """ - super(DataPluginAction, self).__init__(**kws) + super().__init__(**kws) if self.data_model_service is None: self.data_model_service = "service://%s" % IDATA_MODEL diff --git a/examples/plugins/single_project/sample_project/data/plugin/ui_service.py b/examples/plugins/single_project/sample_project/data/plugin/ui_service.py index 9515fdf3f..d2dc571d8 100644 --- a/examples/plugins/single_project/sample_project/data/plugin/ui_service.py +++ b/examples/plugins/single_project/sample_project/data/plugin/ui_service.py @@ -56,7 +56,7 @@ def __init__(self, **kws): """ - super(UiService, self).__init__(**kws) + super().__init__(**kws) # Ensure we have a default model-service if one wasn't specified. if self.model_service is None: diff --git a/examples/plugins/single_project/sample_project/plugins/single_project/env_project.py b/examples/plugins/single_project/sample_project/plugins/single_project/env_project.py index 90c5f4422..ef2701f72 100644 --- a/examples/plugins/single_project/sample_project/plugins/single_project/env_project.py +++ b/examples/plugins/single_project/sample_project/plugins/single_project/env_project.py @@ -91,7 +91,7 @@ def __getstate__(self): """ # Obtain state from base class(es) - state = super(EnvProject, self).__getstate__() + state = super().__getstate__() # Add in our current version number. Note use a different attribute # name from any base or derived class so that our numbers don't @@ -127,7 +127,7 @@ def __setstate__(self, state): ) # Restore the base class's state. - super(EnvProject, self).__setstate__(state) + super().__setstate__(state) return diff --git a/examples/plugins/tasks/ipython_kernel/python_editor.py b/examples/plugins/tasks/ipython_kernel/python_editor.py index 4af703e19..ca060cea4 100644 --- a/examples/plugins/tasks/ipython_kernel/python_editor.py +++ b/examples/plugins/tasks/ipython_kernel/python_editor.py @@ -147,7 +147,7 @@ class PythonEditorEventFilter(QtCore.QObject): """ def __init__(self, editor, parent): - super(PythonEditorEventFilter, self).__init__(parent) + super().__init__(parent) self.__editor = editor def eventFilter(self, obj, event): @@ -190,4 +190,4 @@ def eventFilter(self, obj, event): event=event, ) - return super(PythonEditorEventFilter, self).eventFilter(obj, event) + return super().eventFilter(obj, event)