Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "super" usage #789

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions enable/abstract_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _do_layout(self, component=None):
def __init__(self, component=None, **kw):
if component is not None:
kw["component"] = component
super(AbstractOverlay, self).__init__(**kw)
super().__init__(**kw)

def do_layout(self, size=None, force=False, component=None):
""" Tells this component to do a layout at a given size. This differs
Expand Down Expand Up @@ -94,4 +94,4 @@ def _request_redraw(self):
"""
if self.component is not None:
self.component.request_redraw()
super(AbstractOverlay, self)._request_redraw()
super()._request_redraw()
2 changes: 1 addition & 1 deletion enable/base_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class BaseTool(Interactor):
def __init__(self, component=None, **traits):
if component is not None:
traits["component"] = component
super(BaseTool, self).__init__(**traits)
super().__init__(**traits)

def dispatch(self, event, suffix):
""" Dispatches a mouse event based on the current event state.
Expand Down
2 changes: 1 addition & 1 deletion enable/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def remove(self, *components):
def draw(self, gc, view_bounds=None, mode="normal"):
if self.view_bounds is None:
self.view_bounds = view_bounds
super(Canvas, self).draw(gc, view_bounds, mode)
super().draw(gc, view_bounds, mode)

# ------------------------------------------------------------------------
# Protected methods
Expand Down
4 changes: 2 additions & 2 deletions enable/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ def __init__(self, **traits):
# After the component is otherwise configured, make sure our
# container gets notified of our being added to it.
container = traits.pop("container")
super(Component, self).__init__(**traits)
super().__init__(**traits)
self._set_padding_traits(padding, padding_traits)
container.add(self)
else:
super(Component, self).__init__(**traits)
super().__init__(**traits)
self._set_padding_traits(padding, padding_traits)

def draw(self, gc, view_bounds=None, mode="default"):
Expand Down
2 changes: 1 addition & 1 deletion enable/component_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def dispose(self):
self._window.cleanup()
self._window = None
self._parent = None
super(_ComponentEditor, self).dispose()
super().dispose()

def update_editor(self):
""" Updates the editor when the object trait changes externally to the
Expand Down
2 changes: 1 addition & 1 deletion enable/constraints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def will_transfer(self):
def _bounds_changed(self, old, new):
""" Run the solver when the container's bounds change.
"""
super(ConstraintsContainer, self)._bounds_changed(old, new)
super()._bounds_changed(old, new)
self.refresh()

def _layout_constraints_changed(self):
Expand Down
6 changes: 3 additions & 3 deletions enable/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def _container_handle_mouse_event(self, event, suffix):
should be set to True, and contained components will not be called
with the event.
"""
# super(Container, self)._dispatch_stateful_event(event, suffix)
# super()._dispatch_stateful_event(event, suffix)
Component._dispatch_stateful_event(self, event, suffix)

def get_event_transform(self, event=None, suffix=""):
Expand Down Expand Up @@ -574,12 +574,12 @@ def _fit_window_changed(self, old, new):
def _bounds_changed(self, old, new):
# crappy... calling our parent's handler seems like a common traits
# event handling problem
Comment on lines 575 to 576
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this same thing when reviewing recent chaco PRs...

super(Container, self)._bounds_changed(old, new)
super()._bounds_changed(old, new)
self._layout_needed = True
self.invalidate_draw()

def _bounds_items_changed(self, event):
super(Container, self)._bounds_items_changed(event)
super()._bounds_items_changed(event)
self._layout_needed = True
self.invalidate_draw()

Expand Down
8 changes: 4 additions & 4 deletions enable/drawing/drawing_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class ToolbarButton(Button):

def __init__(self, *args, **kw):
toolbar = kw.pop("toolbar", None)
super(ToolbarButton, self).__init__(*args, **kw)
super().__init__(*args, **kw)
if toolbar:
self.toolbar = toolbar
toolbar.add(self)
Expand Down Expand Up @@ -171,7 +171,7 @@ def _canvas_bounds_updated(self, event):
self.y = self.canvas.height - self.height

def _dispatch_stateful_event(self, event, suffix):
super(DrawingCanvasToolbar, self)._dispatch_stateful_event(
super()._dispatch_stateful_event(
event, suffix
)
event.handled = True
Expand Down Expand Up @@ -219,7 +219,7 @@ def dispatch(self, event, suffix):
for tool in self.listening_tools:
tool.dispatch(event, suffix)

super(DrawingCanvas, self).dispatch(event, suffix)
super().dispatch(event, suffix)

def activate(self, tool):
"""
Expand All @@ -233,7 +233,7 @@ def _draw_container_mainlayer(self, gc, view_bounds=None, mode="default"):
if active_tool and active_tool.draw_mode == "exclusive":
active_tool.draw(gc, view_bounds, mode)
else:
# super(DrawingCanvas, self)._draw(gc, view_bounds, mode)
# super()._draw(gc, view_bounds, mode)
for tool in self.listening_tools:
tool.draw(gc, view_bounds, mode)
if active_tool:
Expand Down
4 changes: 2 additions & 2 deletions enable/examples/demo/enable/container_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Region(PlotComponent, DragTool):
_offset = Tuple

def __init__(self, color=None, **kw):
super(Region, self).__init__(**kw)
super().__init__(**kw)
if color:
self.color = color
if "bounds" not in kw:
Expand Down Expand Up @@ -55,7 +55,7 @@ class Overlay(AbstractOverlay):
margin = Int(8)

def __init__(self, text="", *args, **kw):
super(Overlay, self).__init__(*args, **kw)
super().__init__(*args, **kw)
self.text = text

def overlay(self, component, gc, view_bounds=None, mode="normal"):
Expand Down
4 changes: 2 additions & 2 deletions enable/examples/demo/savage/buttons_on_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CanvasButton(Component):
bounds = [64, 64]

def __init__(self, filename, callback, callback_args, *args, **kw):
super(CanvasButton, self).__init__(*args, **kw)
super().__init__(*args, **kw)

self.document = self._load_svg_document(filename)

Expand Down Expand Up @@ -135,7 +135,7 @@ class ButtonCanvasView(HasTraits):
)

def __init__(self, *args, **kw):
super(ButtonCanvasView, self).__init__(*args, **kw)
super().__init__(*args, **kw)
self.add_buttons()

def _canvas_default(self):
Expand Down
2 changes: 1 addition & 1 deletion enable/examples/demo/savage/static_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StaticImageExample(HasTraits):
)

def __init__(self, filename, renderer, *args, **kw):
super(StaticImageExample, self).__init__(*args, **kw)
super().__init__(*args, **kw)

self.svg = SVGDocument.createFromFile(filename, renderer=renderer)

Expand Down
8 changes: 3 additions & 5 deletions enable/graphics_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,13 @@ class EnableGCMixin(object):
def __init__(self, *args, **kwargs):
if "window" in kwargs:
self.window = kwargs.pop("window")
super(EnableGCMixin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def clip_to_rect(self, x, y, width, height):
if getattr(self, "corner_pixel_origin", True):
super(EnableGCMixin, self).clip_to_rect(
x - 0.5, y - 0.5, width + 1, height + 1
)
super().clip_to_rect(x - 0.5, y - 0.5, width + 1, height + 1)
else:
super(EnableGCMixin, self).clip_to_rect(x, y, width, height)
super().clip_to_rect(x, y, width, height)

def clear_clip(self, color, coordinates):
""" Clip and clear a Kiva graphics context to a specified area and
Expand Down
4 changes: 2 additions & 2 deletions enable/layout/constraints_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __getattr__(self, name):

"""
try:
return super(ConstraintsNamespace, self).__getattr__(name)
return super().__getattr__(name)
except AttributeError:
pass

Expand All @@ -77,4 +77,4 @@ def __setattr__(self, name, value):
if isinstance(value, LinearSymbolic):
self._constraints[name] = value
else:
super(ConstraintsNamespace, self).__setattr__(name, value)
super().__setattr__(name, value)
12 changes: 6 additions & 6 deletions enable/layout/layout_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __init__(self, func, *args, **kwds):
**kwds
The keyword arguments to pass to 'func'.
"""
super(DeferredConstraintsFunction, self).__init__()
super().__init__()
self.func = func
self.args = args
self.kwds = kwds
Expand Down Expand Up @@ -228,7 +228,7 @@ def __init__(self, orientation, *items, **config):
inter-element spacing to use during abutment. The
default is the value of DefaultSpacing.ABUTMENT.
"""
super(AbutmentHelper, self).__init__()
super().__init__()
self.orientation = orientation
self.items = items
self.spacing = config.get("spacing", DefaultSpacing.ABUTMENT)
Expand Down Expand Up @@ -277,7 +277,7 @@ def __init__(self, anchor, *items, **config):
inter-element spacing to use during alignement. The
default is the value of DefaultSpacing.ALIGNMENT.
"""
super(AlignmentHelper, self).__init__()
super().__init__()
self.anchor = anchor
self.items = items
self.spacing = config.get("spacing", DefaultSpacing.ALIGNMENT)
Expand Down Expand Up @@ -322,7 +322,7 @@ def __init__(self, name):
A string name to prepend to a unique owner id generated
for this box helper, to aid in debugging.
"""
super(BoxHelper, self).__init__()
super().__init__()
owner = uuid4().hex[:8]
self.constraints_id = name + "|" + owner
self._namespace = ConstraintsNamespace(name, owner)
Expand Down Expand Up @@ -382,7 +382,7 @@ def __init__(self, orientation, *items, **config):
the bounds of the box. The default is the value of
DefaultSpacing.BOX_MARGIN.
"""
super(LinearBoxHelper, self).__init__(orientation[0] + "box")
super().__init__(orientation[0] + "box")
self.items = items
self.orientation = orientation
self.ortho_orientation = self.ortho_map[orientation]
Expand Down Expand Up @@ -562,7 +562,7 @@ def __init__(self, *rows, **config):
the bounds of the grid. The default is the value of
DefaultSpacing.BOX_MARGIN.
"""
super(GridHelper, self).__init__("grid")
super().__init__("grid")
self.grid_rows = rows
self.row_align = config.get("row_align", "")
self.col_align = config.get("col_align", "")
Expand Down
4 changes: 1 addition & 3 deletions enable/null/quartz.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ def __init__(self, size_or_array, *args, **kwds):
# No initialization.
image = None
width, height = size_or_array
super(GraphicsContext, self).__init__(
(width, height), gc, *args, **kwds
)
super().__init__((width, height), gc, *args, **kwds)
if image is not None:
self.draw_image(image)

Expand Down
2 changes: 1 addition & 1 deletion enable/primitives/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def from_file(cls, filename, **traits):
def __init__(self, data, **traits):
# the default bounds are the size of the image
traits.setdefault("bounds", data.shape[1::-1])
super(Image, self).__init__(data=data, **traits)
super().__init__(data=data, **traits)

def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"):
""" Draws the image. """
Expand Down
14 changes: 7 additions & 7 deletions enable/qt4/base_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ class _QtWindow(QtGui.QWidget):
""" The Qt widget that implements the enable control. """

def __init__(self, parent, enable_window):
super(_QtWindow, self).__init__(parent)
super().__init__(parent)
self.setAcceptDrops(True)
self.handler = _QtWindowHandler(self, enable_window)

def closeEvent(self, event):
self.handler.closeEvent(event)
return super(_QtWindow, self).closeEvent(event)
return super().closeEvent(event)

def paintEvent(self, event):
self.handler.paintEvent(event)
Expand Down Expand Up @@ -285,26 +285,26 @@ def dropEvent(self, event):
self.handler.dropEvent(event)

def sizeHint(self):
qt_size_hint = super(_QtWindow, self).sizeHint()
qt_size_hint = super().sizeHint()
return self.handler.sizeHint(qt_size_hint)


class _QtGLWindow(QtOpenGL.QGLWidget):
def __init__(self, parent, enable_window):
super(_QtGLWindow, self).__init__(parent)
super().__init__(parent)
self.handler = _QtWindowHandler(self, enable_window)

def closeEvent(self, event):
self.handler.closeEvent(event)
return super(_QtGLWindow, self).closeEvent(event)
return super().closeEvent(event)

def paintEvent(self, event):
super(_QtGLWindow, self).paintEvent(event)
super().paintEvent(event)
self.handler.paintEvent(event)
self.swapBuffers()

def resizeEvent(self, event):
super(_QtGLWindow, self).resizeEvent(event)
super().resizeEvent(event)
self.handler.resizeEvent(event)

def keyPressEvent(self, event):
Expand Down
2 changes: 1 addition & 1 deletion enable/qt4/gl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _init_gc(self):
"""
self.control.makeCurrent()
self._fake_pyglet_context.set_current()
super(Window, self)._init_gc()
super()._init_gc()

def _paint(self, event=None):
""" Paint the contents of the window.
Expand Down
10 changes: 5 additions & 5 deletions enable/qt4/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class QResizableScrollBar(QtGui.QScrollBar):
resized = QtCore.Signal()

def resizeEvent(self, event):
super(QResizableScrollBar, self).resizeEvent(event)
super().resizeEvent(event)
self.resized.emit()


Expand Down Expand Up @@ -277,22 +277,22 @@ def _scroll_position_changed(self):
self.request_redraw()

def _bounds_changed(self, old, new):
super(NativeScrollBar, self)._bounds_changed(old, new)
super()._bounds_changed(old, new)
self._widget_moved = True
self.request_redraw()

def _bounds_items_changed(self, event):
super(NativeScrollBar, self)._bounds_items_changed(event)
super()._bounds_items_changed(event)
self._widget_moved = True
self.request_redraw()

def _position_changed(self, old, new):
super(NativeScrollBar, self)._position_changed(old, new)
super()._position_changed(old, new)
self._widget_moved = True
self.request_redraw()

def _position_items_changed(self, event):
super(NativeScrollBar, self)._position_items_changed(event)
super()._position_items_changed(event)
self._widget_moved = True
self.request_redraw()

Expand Down
4 changes: 2 additions & 2 deletions enable/savage/compliance/comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ComponentTrait(Instance):

def __init__(self, **kwds):
kwds.setdefault("klass", Component)
super(ComponentTrait, self).__init__(**kwds)
super().__init__(**kwds)

def create_editor(self):
return ComponentEditor()
Expand Down Expand Up @@ -218,7 +218,7 @@ class Comparator(HasTraits):
)

def __init__(self, **traits):
super(Comparator, self).__init__(**traits)
super().__init__(**traits)
kiva_ch = activate_tool(
self.kiva_component, Crosshair(self.kiva_component)
)
Expand Down
2 changes: 1 addition & 1 deletion enable/savage/compliance/crosshair.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class MultiController(HasTraits):
crosshairs = List()

def __init__(self, *crosshairs, **traits):
super(MultiController, self).__init__(**traits)
super().__init__(**traits)
for ch in crosshairs:
self.add(ch)

Expand Down
Loading