Repository: spyder-ide/spyder

Issue:
Move breakpoints plugin to python3 only
Take into account the following:

- [ ] Update `super()` use
- [ ] Remove the `py3compat` module
- [ ] Update any code (and remove if necessary) that uses `if PY2` etc...
- [ ] Check division operator
- [ ] Remove future imports
- [ ] Check tests
- [ ] Check for Py2 of Py3 codes


Discussion:
https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L53

`QAbstractTableModel.__init__(self, parent)` ->

`super().__init__(parent)`

Resolving patch:
diff --git a/spyder/plugins/breakpoints/plugin.py b/spyder/plugins/breakpoints/plugin.py
--- a/spyder/plugins/breakpoints/plugin.py
+++ b/spyder/plugins/breakpoints/plugin.py
@@ -37,7 +37,7 @@ class Breakpoints(SpyderPluginWidget):
 
     def __init__(self, parent=None):
         """Initialization."""
-        SpyderPluginWidget.__init__(self, parent)
+        super().__init__(parent)
 
         self.breakpoints = BreakpointWidget(self,
                                             options_button=self.options_button)
@@ -51,7 +51,7 @@ def __init__(self, parent=None):
         path = osp.join(self.PLUGIN_PATH, self.IMG_PATH)
         self.icon = ima.icon('breakpoints', icon_path=path)
 
-    #------ SpyderPluginWidget API --------------------------------------------
+    # ----- SpyderPluginWidget API --------------------------------------------
     def get_plugin_title(self):
         """Return widget title"""
         return _("Breakpoints")
@@ -74,7 +74,6 @@ def on_first_registration(self):
     def register_plugin(self):
         """Register plugin in Spyder's main window"""
         self.breakpoints.edit_goto.connect(self.main.editor.load)
-        #self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
         self.breakpoints.clear_all_breakpoints.connect(
                                         self.main.editor.clear_all_breakpoints)
         self.breakpoints.clear_breakpoint.connect(
diff --git a/spyder/plugins/breakpoints/widgets/breakpointsgui.py b/spyder/plugins/breakpoints/widgets/breakpointsgui.py
--- a/spyder/plugins/breakpoints/widgets/breakpointsgui.py
+++ b/spyder/plugins/breakpoints/widgets/breakpointsgui.py
@@ -39,8 +39,8 @@
 
 COLUMN_COUNT = 4
 EXTRA_COLUMNS = 1
-COL_FILE, COL_LINE, COL_CONDITION, COL_BLANK, COL_FULL = range(COLUMN_COUNT +
-                                                               EXTRA_COLUMNS)
+COL_FILE, COL_LINE, COL_CONDITION, COL_BLANK, COL_FULL = list(
+    range(COLUMN_COUNT + EXTRA_COLUMNS))
 COLUMN_HEADERS = (_("File"), _("Line"), _("Condition"), (""))
 
 
@@ -50,7 +50,7 @@ class BreakpointTableModel(QAbstractTableModel):
     """
 
     def __init__(self, parent, data):
-        QAbstractTableModel.__init__(self, parent)
+        super().__init__(parent)
         if data is None:
             data = {}
         self._data = None
@@ -63,7 +63,7 @@ def set_data(self, data):
         self.breakpoints = []
         files = []
         # Generate list of filenames with active breakpoints
-        for key in data.keys():
+        for key in data:
             if data[key] and key not in files:
                 files.append(key)
         # Insert items
@@ -137,7 +137,7 @@ def reset(self):
 
 class BreakpointDelegate(QItemDelegate):
     def __init__(self, parent=None):
-        QItemDelegate.__init__(self, parent)
+        super().__init__(parent)
 
 
 class BreakpointTableView(QTableView):
@@ -147,7 +147,7 @@ class BreakpointTableView(QTableView):
     set_or_edit_conditional_breakpoint = Signal()
 
     def __init__(self, parent, data):
-        QTableView.__init__(self, parent)
+        super().__init__(parent)
         self.model = BreakpointTableModel(self, data)
         self.setModel(self.model)
         self.delegate = BreakpointDelegate(self)
@@ -184,35 +184,29 @@ def contextMenuEvent(self, event):
         index_clicked = self.indexAt(event.pos())
         actions = []
         self.popup_menu = QMenu(self)
-        clear_all_breakpoints_action = create_action(self,
-            _("Clear breakpoints in all files"),
+        clear_all_breakpoints_action = create_action(
+            self, _("Clear breakpoints in all files"),
             triggered=lambda: self.clear_all_breakpoints.emit())
         actions.append(clear_all_breakpoints_action)
         if self.model.breakpoints:
             c_row = index_clicked.row()
             filename = self.model.breakpoints[c_row][COL_FULL]
             lineno = int(self.model.breakpoints[c_row][COL_LINE])
-            # QAction.triggered works differently for PySide and PyQt
-            if not API == 'pyside':
-                clear_slot = lambda _checked, filename=filename, lineno=lineno: \
-                    self.clear_breakpoint.emit(filename, lineno)
-                edit_slot = lambda _checked, filename=filename, lineno=lineno: \
-                    (self.edit_goto.emit(filename, lineno, ''),
-                     self.set_or_edit_conditional_breakpoint.emit())
-            else:
-                clear_slot = lambda filename=filename, lineno=lineno: \
-                    self.clear_breakpoint.emit(filename, lineno)
-                edit_slot = lambda filename=filename, lineno=lineno: \
-                    (self.edit_goto.emit(filename, lineno, ''),
-                     self.set_or_edit_conditional_breakpoint.emit())
-
-            clear_breakpoint_action = create_action(self,
-                    _("Clear this breakpoint"),
+
+            def clear_slot(filename=filename, lineno=lineno):
+                return self.clear_breakpoint.emit(filename, lineno)
+
+            def edit_slot(filename=filename, lineno=lineno):
+                self.edit_goto.emit(filename, lineno, '')
+                self.set_or_edit_conditional_breakpoint.emit()
+
+            clear_breakpoint_action = create_action(
+                    self, _("Clear this breakpoint"),
                     triggered=clear_slot)
-            actions.insert(0,clear_breakpoint_action)
+            actions.insert(0, clear_breakpoint_action)
 
-            edit_breakpoint_action = create_action(self,
-                    _("Edit this breakpoint"),
+            edit_breakpoint_action = create_action(
+                    self, _("Edit this breakpoint"),
                     triggered=edit_slot)
             actions.append(edit_breakpoint_action)
         add_actions(self.popup_menu, actions)
@@ -231,11 +225,11 @@ class BreakpointWidget(QWidget):
     edit_goto = Signal(str, int, str)
 
     def __init__(self, parent, options_button=None):
-        QWidget.__init__(self, parent)
+        super().__init__(parent)
 
         self.setWindowTitle("Breakpoints")
         self.dictwidget = BreakpointTableView(self,
-                               self._load_all_breakpoints())
+                                              self._load_all_breakpoints())
         if options_button:
             btn_layout = QHBoxLayout()
             btn_layout.setAlignment(Qt.AlignLeft)
@@ -272,9 +266,9 @@ def set_data(self):
         self.dictwidget.sortByColumn(COL_FILE, Qt.DescendingOrder)
 
 
-#==============================================================================
+# =============================================================================
 # Tests
-#==============================================================================
+# =============================================================================
 def test():
     """Run breakpoint widget test"""
     from spyder.utils.qthelpers import qapplication


Test patch: