Commit d2bc5091 authored by Samuel GAIST's avatar Samuel GAIST

Merge branch 'move_super_to_python3_recommendations' into 'v2'

Move super to python3 recommendations

See merge request !110
parents ccddb740 5a2abd72
Pipeline #33293 passed with stage
in 11 minutes and 53 seconds
......@@ -45,7 +45,7 @@ class AssetModel(QStringListModel):
def __init__(self, parent=None):
"""Constructor"""
super(QStringListModel, self).__init__(parent)
super().__init__(parent)
self.__latest_only = True
self.__prefix_path = None
......
......@@ -33,7 +33,7 @@ class AssetItemDelegate(QStyledItemDelegate):
"""Delegate to edit asset entries"""
def __init__(self, asset_model, parent=None):
super(AssetItemDelegate, self).__init__(parent)
super().__init__(parent)
if not isinstance(asset_model, AssetModel):
raise TypeError("Wrong model type")
......
......@@ -63,4 +63,4 @@ class MouseWheelFilter(QObject):
event.ignore()
return True
return super(MouseWheelFilter, self).eventFilter(obj, event)
return super().eventFilter(obj, event)
......@@ -91,9 +91,7 @@ class ParameterTypeTestDelegate(ParameterTypeDelegate):
def createEditor(self, parent, options, index):
"""Force commit to model on index change, otherwise testing won't work"""
combobox = super(ParameterTypeTestDelegate, self).createEditor(
parent, options, index
)
combobox = super().createEditor(parent, options, index)
combobox.currentIndexChanged.connect(lambda: self.commitData.emit(combobox))
return combobox
......
......@@ -42,7 +42,7 @@ class MockAssetEditor(AbstractAssetEditor):
"""
def __init__(self, parent=None):
super(MockAssetEditor, self).__init__(AssetType.UNKNOWN, parent)
super().__init__(AssetType.UNKNOWN, parent)
self.dataformat_model = None
self.add_field_button = QPushButton(self.tr("Add"))
self.layout().addWidget(self.add_field_button)
......
......@@ -42,7 +42,7 @@ class ChangeWidget(QWidget):
dataChanged = pyqtSignal()
def __init__(self, parent=None):
super(ChangeWidget, self).__init__(parent)
super().__init__(parent)
self._prefix_path = None
......
......@@ -152,7 +152,7 @@ class PropertyEditor(QWidget):
analyzerStateChanged = pyqtSignal(bool)
def __init__(self, parent=None):
super(PropertyEditor, self).__init__(parent)
super().__init__(parent)
self.language = "unknown"
self.schema_version = DEFAULT_SCHEMA_VERSION
......@@ -323,7 +323,7 @@ class DeletableEditor(QWidget):
deletionRequested = pyqtSignal()
def __init__(self, parent=None):
super(DeletableEditor, self).__init__(parent=None)
super().__init__(parent=None)
self.delete_button = QPushButton(self.tr("-"))
self.delete_button.setFixedSize(30, 30)
......@@ -343,7 +343,7 @@ class ParameterEditor(DeletableEditor):
"""Editor for a parameter"""
def __init__(self, parent=None):
super(ParameterEditor, self).__init__(parent=None)
super().__init__(parent=None)
self.name_lineedit = QLineEdit()
self.parameter_widget = ParameterWidget()
......@@ -373,7 +373,7 @@ class ResultEditor(DeletableEditor):
"""Editor for results"""
def __init__(self, dataformat_model, parent=None):
super(ResultEditor, self).__init__(parent)
super().__init__(parent)
proxy_model = QSortFilterProxyModel()
proxy_model.setSourceModel(dataformat_model)
......@@ -418,7 +418,7 @@ class IOWidget(QGroupBox):
dataChanged = pyqtSignal()
def __init__(self, title, dataformat_model, parent=None):
super(IOWidget, self).__init__(title, parent)
super().__init__(title, parent)
self.dataformat_model = dataformat_model
delegate = AssetItemDelegate(self.dataformat_model)
......@@ -502,7 +502,7 @@ class GroupEditor(DeletableEditor):
"""Editor for input/output group"""
def __init__(self, dataformat_model, parent=None):
super(GroupEditor, self).__init__(parent)
super().__init__(parent)
self.dataformat_model = dataformat_model
......@@ -596,7 +596,7 @@ class GroupEditor(DeletableEditor):
@frozen
class AlgorithmEditor(AbstractAssetEditor):
def __init__(self, parent=None):
super(AlgorithmEditor, self).__init__(AssetType.ALGORITHM, parent)
super().__init__(AssetType.ALGORITHM, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Algorithm"))
......
......@@ -61,9 +61,7 @@ class AssetFilterProxyModel(QSortFilterProxyModel):
except RuntimeError:
return False
return super(AssetFilterProxyModel, self).filterAcceptsRow(
source_row, source_parent
)
return super().filterAcceptsRow(source_row, source_parent)
class AssetItemDelegate(QStyledItemDelegate):
......@@ -75,7 +73,7 @@ class AssetItemDelegate(QStyledItemDelegate):
:param file_extension str: file extension to filter the text from
"""
super(AssetItemDelegate, self).__init__(parent)
super().__init__(parent)
self.file_extension = file_extension
def displayText(self, value, locale):
......@@ -83,7 +81,7 @@ class AssetItemDelegate(QStyledItemDelegate):
if value.endswith(self.file_extension):
return value.split(".")[0]
return super(AssetItemDelegate, self).displayText(value, locale)
return super().displayText(value, locale)
class AssetBrowser(QWidget):
......@@ -97,7 +95,7 @@ class AssetBrowser(QWidget):
def __init__(self, parent=None):
"""Constructor"""
super(AssetBrowser, self).__init__(parent)
super().__init__(parent)
self.contextual_menu = None
self.filesystem_model = QFileSystemModel()
self.filesystem_model.setNameFilters(["*.json"])
......
......@@ -132,7 +132,7 @@ class AssetWidget(QWidget):
def __init__(self, parent=None):
"""Constructor"""
super(AssetWidget, self).__init__(parent)
super().__init__(parent)
self.context = None
self.current_asset = None
......@@ -287,7 +287,7 @@ class AssetWidget(QWidget):
"""Re-impl will check and ask to save if the editor is dirty"""
self.maybe_save()
super(AssetWidget, self).closeEvent(event)
super().closeEvent(event)
def maybe_save(self):
"""If the editor has been modified ask for saving"""
......
......@@ -69,7 +69,7 @@ from .utils import create_delete_button_and_layout
class SelectableLabel(QLabel):
def __init__(self, parent=None):
super(SelectableLabel, self).__init__(parent)
super().__init__(parent)
self.setTextInteractionFlags(
QtCore.Qt.TextSelectableByMouse | QtCore.Qt.TextSelectableByKeyboard
)
......@@ -77,7 +77,7 @@ class SelectableLabel(QLabel):
class SetViewer(QWidget):
def __init__(self, parent=None):
super(SetViewer, self).__init__(parent)
super().__init__(parent)
self.name_label = SelectableLabel()
self.template_label = SelectableLabel()
......@@ -118,7 +118,7 @@ class SetViewer(QWidget):
class ProtocolViewer(QWidget):
def __init__(self, parent=None):
super(ProtocolViewer, self).__init__(parent)
super().__init__(parent)
self.set_viewers = []
......@@ -148,7 +148,7 @@ class ProtocolViewer(QWidget):
class DatabaseV1Viewer(QWidget):
def __init__(self, parent=None):
super(DatabaseV1Viewer, self).__init__(parent)
super().__init__(parent)
self.scroll_widget = ScrollWidget()
......@@ -179,7 +179,7 @@ class ParameterTypeDelegate(QStyledItemDelegate):
"""Delegate to edit parameter type entries"""
def __init__(self, parameter_type_model, parent=None):
super(ParameterTypeDelegate, self).__init__(parent)
super().__init__(parent)
self.parameter_type_model = parameter_type_model
def createEditor(self, parent, options, index):
......@@ -211,14 +211,14 @@ class ParameterTypeDelegate(QStyledItemDelegate):
model.setData(sibling, data)
super(ParameterTypeDelegate, self).setModelData(editor, model, index)
super().setModelData(editor, model, index)
class ParameterValueDelegate(QStyledItemDelegate):
"""Delegate to edit parameter type entries"""
def __init__(self, parent=None):
super(ParameterValueDelegate, self).__init__(parent)
super().__init__(parent)
def createEditor(self, parent, options, index):
if is_Qt_equal_or_higher("5.11"):
......@@ -234,9 +234,7 @@ class ParameterValueDelegate(QStyledItemDelegate):
elif parameter_type == "number":
return QDoubleSpinBox(parent)
else:
return super(ParameterValueDelegate, self).createEditor(
parent, options, index
)
return super().createEditor(parent, options, index)
class ViewEditor(QWidget):
......@@ -245,7 +243,7 @@ class ViewEditor(QWidget):
deletionRequested = pyqtSignal()
def __init__(self, parent=None):
super(ViewEditor, self).__init__(parent)
super().__init__(parent)
self.parameter_type_model = QStringListModel()
self.parameter_type_model.setStringList(["string", "number", "boolean"])
......@@ -406,7 +404,7 @@ class ViewsEditor(QWidget):
dataChanged = pyqtSignal()
def __init__(self, parent=None):
super(ViewsEditor, self).__init__(parent)
super().__init__(parent)
self.protocol = None
self.prefix_path = None
......@@ -501,7 +499,7 @@ class ProtocolEditor(QWidget):
deletionRequested = pyqtSignal()
def __init__(self, parent=None):
super(ProtocolEditor, self).__init__(parent)
super().__init__(parent)
self.delete_button, delete_layout = create_delete_button_and_layout()
......@@ -565,7 +563,7 @@ class ProtocolDialog(QDialog):
"""Dialog to get necessary info for a new protocol entry"""
def __init__(self, used_names, protocoltemplate_model, parent=None):
super(ProtocolDialog, self).__init__(parent)
super().__init__(parent)
self.used_names = used_names
......@@ -624,7 +622,7 @@ class DatabaseWidget(QWidget):
dataChanged = pyqtSignal()
def __init__(self, parent=None):
super(DatabaseWidget, self).__init__(parent)
super().__init__(parent)
self.protocoltemplate_model = AssetModel()
self.protocoltemplate_model.asset_type = AssetType.PROTOCOLTEMPLATE
......@@ -718,7 +716,7 @@ class DatabaseWidget(QWidget):
@frozen
class DatabaseEditor(AbstractAssetEditor):
def __init__(self, parent=None):
super(DatabaseEditor, self).__init__(AssetType.DATABASE, parent)
super().__init__(AssetType.DATABASE, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Database"))
......
......@@ -112,7 +112,7 @@ class DataformatBaseWidget(QWidget):
:param parent QWidget: parent of this widget
"""
super(DataformatBaseWidget, self).__init__(parent)
super().__init__(parent)
self.__has_name = False
......@@ -188,7 +188,7 @@ class DataformatWidget(DataformatBaseWidget):
:param parent QWidget: parent of this widget
"""
super(DataformatWidget, self).__init__(parent)
super().__init__(parent)
self.dataformat_model = dataformat_model
self.dataformat_box = QComboBox()
......@@ -229,7 +229,7 @@ class DataformatObjectWidget(DataformatBaseWidget):
:param parent QWidget: parent of this widget
"""
super(DataformatObjectWidget, self).__init__(parent)
super().__init__(parent)
self.dataformat_model = dataformat_model
self.dataformat_widgets = []
......@@ -358,7 +358,7 @@ class DimensionWidget(DataformatBaseWidget):
:param parent QWidget: parent of this widget
"""
super(DimensionWidget, self).__init__(parent)
super().__init__(parent)
self.setHasName(False)
......@@ -401,7 +401,7 @@ class DataformatArrayWidget(DataformatBaseWidget):
:param parent QWidget: parent of this widget
"""
super(DataformatArrayWidget, self).__init__(parent)
super().__init__(parent)
self.dataformat_model = dataformat_model
self.dimension_widgets = []
......@@ -556,7 +556,7 @@ class DataformatEditor(AbstractAssetEditor):
:param parent QWidget: parent of this widget
"""
super(DataformatEditor, self).__init__(AssetType.DATAFORMAT, parent)
super().__init__(AssetType.DATAFORMAT, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Dataformat"))
......
......@@ -62,7 +62,7 @@ class CreationType:
class AssetCreationDialog(QDialog, CreationType):
def __init__(self, context, asset_type, parent=None):
super(AssetCreationDialog, self).__init__(parent)
super().__init__(parent)
config = context.meta["config"]
user = config.user
......@@ -180,7 +180,7 @@ class AssetCreationDialog(QDialog, CreationType):
def open(self, slot):
self.accepted.connect(slot)
super(AssetCreationDialog, self).open()
super().open()
def creationType(self):
"""Returns the type of creation done"""
......
......@@ -61,7 +61,7 @@ class AbstractAssetEditor(QWidget):
if not isinstance(asset_type, AssetType):
raise RuntimeError("Invalid parameter")
super(AbstractAssetEditor, self).__init__(parent)
super().__init__(parent)
self.context = None
self.asset_type = asset_type
......@@ -268,7 +268,7 @@ class PlaceholderEditor(AbstractAssetEditor):
:param parent QWidget: parent of this widget
"""
super(PlaceholderEditor, self).__init__(AssetType.UNKNOWN, parent)
super().__init__(AssetType.UNKNOWN, parent)
self.set_title(self.tr("Nothing to edit"))
self.information_group_box.hide()
self.create_action = None
......
......@@ -32,7 +32,7 @@ from .editor import AbstractAssetEditor
@frozen
class ExperimentEditor(AbstractAssetEditor):
def __init__(self, parent=None):
super(ExperimentEditor, self).__init__(AssetType.EXPERIMENT, parent)
super().__init__(AssetType.EXPERIMENT, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Experiment"))
......
......@@ -35,7 +35,7 @@ class FieldWidget(QWidget):
def __init__(self, dataformat_model, parent=None):
"""Constructor"""
super(FieldWidget, self).__init__(parent)
super().__init__(parent)
self.dataformat_name = QLineEdit()
self.dataformat_box = QComboBox()
......
......@@ -47,7 +47,7 @@ class LibrariesWidget(QWidget):
def __init__(self, parent=None):
"""Constructor"""
super(LibrariesWidget, self).__init__(parent)
super().__init__(parent)
self.setMinimumHeight(200)
self._available_libraries = []
......
......@@ -42,7 +42,7 @@ class LibraryEditor(AbstractAssetEditor):
:param parent QWidget: parent of this widget
"""
super(LibraryEditor, self).__init__(AssetType.LIBRARY, parent)
super().__init__(AssetType.LIBRARY, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Library"))
......
......@@ -43,7 +43,7 @@ class MainWindow(QMainWindow):
def __init__(self, parent=None):
"""Constructor"""
super(MainWindow, self).__init__(parent)
super().__init__(parent)
menubar = self.menuBar()
......
......@@ -105,14 +105,14 @@ class StackedWidget(QStackedWidget):
"""
def __init__(self, parent=None):
super(StackedWidget, self).__init__(parent)
super().__init__(parent)
def sizeHint(self):
"""Returns a size hint based on the current widget in place of the
biggest of all widgets added.
"""
size = super(StackedWidget, self).size()
size = super().size()
current_size_hint = self.currentWidget().sizeHint()
size.setHeight(current_size_hint.height())
return size
......@@ -122,7 +122,7 @@ class StackedWidget(QStackedWidget):
the biggest of all widgets added.
"""
size = super(StackedWidget, self).size()
size = super().size()
current_size_hint = self.currentWidget().minimumSizeHint()
size.setHeight(current_size_hint.height())
return size
......@@ -138,7 +138,7 @@ class NumericalChoiceDialog(QDialog):
:param parent QWidget: parent widget
"""
super(NumericalChoiceDialog, self).__init__(parent)
super().__init__(parent)
self.setWindowTitle(self.tr("Input"))
self.label = QLabel(self.tr("New Choice:"))
......@@ -192,7 +192,7 @@ class BoolSetupWidget(QWidget):
:param parent QWidget: parent widget
"""
super(BoolSetupWidget, self).__init__(parent)
super().__init__(parent)
# Member variables
# Added self for auto-exclusion to work correctly
......@@ -247,7 +247,7 @@ class StringSetupWidget(QWidget):
:param parent QWidget: parent widget
"""
super(StringSetupWidget, self).__init__(parent)
super().__init__(parent)
# Member variables
self.single_button = QRadioButton(self.tr("Single"), self)
......@@ -426,7 +426,7 @@ class NumericalSetupWidget(QWidget):
:param parent QWidget: parent widget
"""
super(NumericalSetupWidget, self).__init__(parent)
super().__init__(parent)
# Class variables
self.current_type = selected_type
......@@ -751,7 +751,7 @@ class ParameterWidget(QWidget):
:param parent QWidget: parent widget
"""
super(ParameterWidget, self).__init__(parent)
super().__init__(parent)
unwanted_basetypes = {"complex64", "complex128"}
basetypes = [
......
......@@ -56,7 +56,7 @@ class ParameterViewer(QWidget):
deletionRequested = pyqtSignal()
def __init__(self, parent=None):
super(ParameterViewer, self).__init__(parent)
super().__init__(parent)
self.delete_button = QPushButton(self.tr("-"))
self.delete_button.setFixedSize(30, 30)
......@@ -105,7 +105,7 @@ class ParameterViewer(QWidget):
@frozen
class PlotterEditor(AbstractAssetEditor):
def __init__(self, parent=None):
super(PlotterEditor, self).__init__(AssetType.PLOTTER, parent)
super().__init__(AssetType.PLOTTER, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Plotter"))
......
......@@ -63,7 +63,7 @@ class ParameterChoiceDialog(QDialog):
:param parent QWidget: parent widget
"""
super(ParameterChoiceDialog, self).__init__(parent)
super().__init__(parent)
self.setWindowTitle(self.tr("Input"))
self.label = QLabel(self.tr("Add Parameter:"))
......@@ -119,7 +119,7 @@ class RestrictedParameterWidget(QWidget):
:param parent QWidget: parent widget
"""
super(RestrictedParameterWidget, self).__init__(parent)
super().__init__(parent)
self._type = data.get("type", None)
self.default = data.get("default", None)
......@@ -251,7 +251,7 @@ class PlotterParameterViewer(QWidget):
:param parent QWidget: parent widget
"""
super(PlotterParameterViewer, self).__init__(parent)
super().__init__(parent)
self.delete_button = QPushButton(self.tr("-"))
self.delete_button.setFixedSize(30, 30)
......@@ -314,9 +314,7 @@ class PlotterParametersEditor(AbstractAssetEditor):
:param parent QWidget: parent widget
"""
super(PlotterParametersEditor, self).__init__(
AssetType.PLOTTERPARAMETER, parent
)
super().__init__(AssetType.PLOTTERPARAMETER, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Plotter Parameters"))
......
......@@ -56,7 +56,7 @@ class SetWidget(QWidget):
deletionRequested = pyqtSignal()
def __init__(self, dataformat_model, parent=None):
super(SetWidget, self).__init__(parent)
super().__init__(parent)
self.dataformat_model = dataformat_model
delegate = AssetItemDelegate(self.dataformat_model)
......@@ -186,7 +186,7 @@ class ProtocolTemplateEditor(AbstractAssetEditor):
"""Editor for protocol template objects"""
def __init__(self, parent=None):
super(ProtocolTemplateEditor, self).__init__(AssetType.PROTOCOLTEMPLATE, parent)
super().__init__(AssetType.PROTOCOLTEMPLATE, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Protocol Template"))
......
......@@ -37,7 +37,7 @@ class EditorListWidget(QWidget):
dataChanged = pyqtSignal()
def __init__(self, parent=None):
super(EditorListWidget, self).__init__(parent)
super().__init__(parent)
self._widget_list = []
......@@ -99,7 +99,7 @@ class ScrollWidget(QScrollArea):
dataChanged = pyqtSignal()
def __init__(self, parent=None):
super(ScrollWidget, self).__init__(parent=None)
super().__init__(parent=None)
self.list_widget = EditorListWidget()
self.setWidget(self.list_widget)
......
......@@ -61,7 +61,7 @@ class NumpySpinBox(QAbstractSpinBox):
:param parent QWidget: parent widget
"""
super(NumpySpinBox, self).__init__(parent)
super().__init__(parent)
self._numpy_type = None
......
......@@ -32,7 +32,7 @@ from .editor import AbstractAssetEditor
@frozen
class ToolchainEditor(AbstractAssetEditor):
def __init__(self, parent=None):
super(ToolchainEditor, self).__init__(AssetType.TOOLCHAIN, parent)
super().__init__(AssetType.TOOLCHAIN, parent)
self.setObjectName(self.__class__.__name__)
self.set_title(self.tr("Toolchain"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment