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

MNT: switch from python2 style super() calls to python3 #1202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion docs/source/_static/tutorials/code/all_motors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class AllMotorsDisplay(Display):
def __init__(self, parent=None, args=[], macros=None):
super(AllMotorsDisplay, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=macros)
# Placeholder for data to filter
self.data = []
# Reference to the PyDMApplication
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_static/tutorials/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BeamPositioning(Display):
def __init__(self, parent=None, args=None):
super(BeamPositioning, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
# Attach our custom process_image method
self.ui.imageView.process_image = self.process_image
# Hook up to the newImageSignal so we can update
Expand Down
4 changes: 2 additions & 2 deletions docs/source/tutorials/action/intro_python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Your display must subclass Display, and implement a few required methods::
from pydm import Display
class MyDisplay(Display):
def __init__(self, parent=None, args=None, macros=None):
super(MyDisplay, self).__init__(parent=parent, args=args, macros=macros)
super().__init__(parent=parent, args=args, macros=macros)

def ui_filename(self):
return 'my_display.ui'
Expand All @@ -65,7 +65,7 @@ Next, we define our Display subclass, and its initializer::

class MyDisplay(Display):
def __init__(self, parent=None, args=None):
super(MyDisplay, self).__init__(parent=parent)
super().__init__(parent=parent)

It is important to remember that you must always call the superclass' initializer
in your own, and pass it the 'parent' argument from your initializer. Otherwise,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/action/little_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This is accomplished by subclassing `pydm.Display` (See :ref:`Display` for more
class BeamPositioning(Display):

def __init__(self, parent=None, args=None, macros=None):
super(BeamPositioning, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=None)
# Attach our custom process_image method
self.ui.imageView.process_image = self.process_image
# Hook up to the newImageSignal so we can update
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/action/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here is how it will look once we are done:

class AllMotorsDisplay(Display):
def __init__(self, parent=None, args=[], macros=None):
super(AllMotorsDisplay, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=None)
# Placeholder for data to filter
self.data = []
# Reference to the PyDMApplication
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorials/intro/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ An example:
class MyDisplay(Display):

def __init__(self, parent=None, args=None, macros=None):
super(MyDisplay, self).__init__(parent=parent, args=args, macros=macros)
super().__init__(parent=parent, args=args, macros=macros)

def file_menu_items(self):
return {"save": self.save_function, "load": (self.load_function, "Ctrl+L")}
Expand Down
2 changes: 1 addition & 1 deletion examples/accessory_window/accessory_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class MyDisplay(Display):
def __init__(self, parent=None, args=[]):
super(MyDisplay, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
self.tracks = [
"Humming",
"Cowboys",
Expand Down
2 changes: 1 addition & 1 deletion examples/archiver_time_plot/archiver_time_plot_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class archiver_time_plot_example(Display):
def __init__(self, parent=None, args=None, macros=None):
super(archiver_time_plot_example, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=macros)
self.app = QApplication.instance()
self.setup_ui()

Expand Down
2 changes: 1 addition & 1 deletion examples/archiver_time_plot/formula_curve_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class archiver_time_plot_example(Display):
def __init__(self, parent=None, args=None, macros=None):
super(archiver_time_plot_example, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=macros)
self.app = QApplication.instance()
self.setup_ui()

Expand Down
2 changes: 1 addition & 1 deletion examples/camviewer/camviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CamViewer(Display):
roi_h_signal = Signal(str)

def __init__(self, parent=None, args=None):
super(CamViewer, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)

# Set up the list of cameras, and all the PVs
test_dict = {
Expand Down
2 changes: 1 addition & 1 deletion examples/code_only/code_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class MyDisplay(Display):
def __init__(self, parent=None, args=[]):
super(MyDisplay, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
self.setup_ui()

def setup_ui(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/exception/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Screen(QtWidgets.QFrame):
def __init__(self, *args, **kwargs):
super(Screen, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.setup_ui()

def setup_ui(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/image_processing/image_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ImageViewer(Display):
def __init__(self, parent=None, args=None):
super(ImageViewer, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
self.markers_lock = threading.Lock()
self.ui.imageView.process_image = self.process_image
self.ui.imageView.newImageSignal.connect(self.draw_markers)
Expand Down
2 changes: 1 addition & 1 deletion examples/macros/macros_and_python/macro_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class MacroAddition(Display):
def __init__(self, parent=None, args=None, macros=None):
super(MacroAddition, self).__init__(parent=parent, macros=macros)
super().__init__(parent=parent, macros=macros)
self.ui.resultLabel.setText("{}".format(float(macros["a"]) + float(macros["b"])))

def ui_filename(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/macros/nested_embedded_windows/macro_addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class MacroAddition(Display):
def __init__(self, parent=None, args=None, macros=None):
super(MacroAddition, self).__init__(parent=parent, macros=macros)
super().__init__(parent=parent, macros=macros)
self.ui.resultLabel.setText("{}".format(float(macros["a"]) + float(macros["b"])))

def ui_filename(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/positioner/positioner_ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

class myDriver(Driver):
def __init__(self):
super(myDriver, self).__init__()
super().__init__()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/positioner/positioner_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Positioner(Display):
def __init__(self, parent=None, args=None):
super(Positioner, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
self.moving = False
self.ui.pushButton.clicked.connect(self.move_motors)
self.motor1pv = epics.PV("MOTOR:1:VAL")
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/all_motors.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class AllMotorsDisplay(Display):
def __init__(self, parent=None, args=[], macros=None):
super(AllMotorsDisplay, self).__init__(parent=parent, args=args, macros=None)
super().__init__(parent=parent, args=args, macros=macros)
# Placeholder for data to filter
self.data = []
# Reference to the PyDMApplication
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BeamPositioning(Display):
def __init__(self, parent=None, args=None):
super(BeamPositioning, self).__init__(parent=parent, args=args)
super().__init__(parent=parent, args=args)
# Attach our custom process_image method
self.ui.imageView.process_image = self.process_image
# Hook up to the newImageSignal so we can update
Expand Down
2 changes: 1 addition & 1 deletion pydm/about_pydm/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class AboutWindow(QWidget):
def __init__(self, parent=None):
super(AboutWindow, self).__init__(parent, Qt.Window)
super().__init__(parent, Qt.Window)
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.pydmVersionLabel.setText(str(self.ui.pydmVersionLabel.text()).format(version=pydm.__version__))
Expand Down
4 changes: 2 additions & 2 deletions pydm/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
fullscreen=False,
home_file=None,
):
super(PyDMApplication, self).__init__(command_line_args)
super().__init__(command_line_args)
# Enable High DPI display, if available.
if hasattr(Qt, "AA_UseHighDpiPixmaps"):
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
Expand Down Expand Up @@ -149,7 +149,7 @@ def exec_(self):
"""
Execute the QApplication.
"""
return super(PyDMApplication, self).exec_()
return super().exec_()

def is_read_only(self):
warnings.warn("'PyDMApplication.is_read_only' is deprecated, " "use 'pydm.data_plugins.is_read_only' instead.")
Expand Down
4 changes: 2 additions & 2 deletions pydm/connection_inspector/connection_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class ConnectionInspector(QWidget):
def __init__(self, parent=None):
super(ConnectionInspector, self).__init__(parent, Qt.Window)
super().__init__(parent, Qt.Window)
connections = self.fetch_data()
self.table_view = ConnectionTableView(connections, self)
self.setLayout(QVBoxLayout(self))
Expand Down Expand Up @@ -89,7 +89,7 @@ def copy_pv_list_to_clipboard(self):

class ConnectionTableView(QTableView):
def __init__(self, connections=[], parent=None):
super(ConnectionTableView, self).__init__(parent)
super().__init__(parent)
self.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContentsOnFirstShow)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.horizontalHeader().setStretchLastSection(True)
Expand Down
4 changes: 2 additions & 2 deletions pydm/connection_inspector/connection_table_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ConnectionTableModel(QAbstractTableModel):
def __init__(self, connections=[], parent=None):
super(ConnectionTableModel, self).__init__(parent=parent)
super().__init__(parent=parent)
self._column_names = ("protocol", "address", "connected")
self.update_timer = QTimer(self)
self.update_timer.setInterval(1000)
Expand Down Expand Up @@ -61,7 +61,7 @@ def data(self, index, role=Qt.DisplayRole):

def headerData(self, section, orientation, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
return super(ConnectionTableModel, self).headerData(section, orientation, role)
return super().headerData(section, orientation, role)
if orientation == Qt.Horizontal and section < self.columnCount():
return str(self._column_names[section]).capitalize()
elif orientation == Qt.Vertical and section < self.rowCount():
Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/calc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def calculate_expression(self):

class Connection(PyDMConnection):
def __init__(self, channel, address, protocol=None, parent=None):
super(Connection, self).__init__(channel, address, protocol, parent)
super().__init__(channel, address, protocol, parent)
self._calc_thread = None
self.value = None
self._configuration = {}
Expand All @@ -190,7 +190,7 @@ def _init_connection(self):

def add_listener(self, channel):
self._setup_calc(channel)
super(Connection, self).add_listener(channel)
super().add_listener(channel)
self.broadcast_value()

def broadcast_value(self):
Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/epics_plugins/caproto_plugin_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

class Connection(PyDMConnection):
def __init__(self, channel, pv, protocol=None, parent=None):
super(Connection, self).__init__(channel, pv, protocol, parent)
super().__init__(channel, pv, protocol, parent)
self.app = QApplication.instance()
self._value = None
self._severity = None
Expand Down Expand Up @@ -194,7 +194,7 @@ def put_value(self, new_val):
logger.exception("Unable to put %s to %s. Exception: %s", new_val, self.pv.pvname, str(e))

def add_listener(self, channel):
super(Connection, self).add_listener(channel)
super().add_listener(channel)
# If we are adding a listener to an already existing PV, we need to
# manually send the signals indicating that the PV is connected, what the latest value is, etc.
if self.pv.connected:
Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/epics_plugins/psp_plugin_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, channel, pv, protocol=None, parent=None):
:param parent: PyQt widget that this widget is inside of.
:type parent: QWidget
"""
super(Connection, self).__init__(channel, pv, protocol, parent)
super().__init__(channel, pv, protocol, parent)
self.python_type = None
self.pv = setup_pv(
pv, con_cb=self.connected_cb, mon_cb=self.monitor_cb, rwaccess_cb=self.rwaccess_cb, control=True
Expand Down Expand Up @@ -524,7 +524,7 @@ def add_listener(self, channel):
:param channel: The channel to connect.
:type channel: :class:`PyDMChannel`
"""
super(Connection, self).add_listener(channel)
super().add_listener(channel)
# If we are adding a listener to an already existing PV, we need to
# manually send the signals indicating that the PV is connected, what
# the latest value is, etc.
Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/epics_plugins/pyepics_plugin_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

class Connection(PyDMConnection):
def __init__(self, channel, pv, protocol=None, parent=None):
super(Connection, self).__init__(channel, pv, protocol, parent)
super().__init__(channel, pv, protocol, parent)
self.app = QApplication.instance()
self.pv = epics.PV(
pv,
Expand Down Expand Up @@ -213,7 +213,7 @@ def put_value(self, new_val):
logger.exception("Unable to put %s to %s. Exception: %s", new_val, self.pv.pvname, str(e))

def add_listener(self, channel):
super(Connection, self).add_listener(channel)
super().add_listener(channel)
# If we are adding a listener to an already existing PV, we need to
# manually send the signals indicating that the PV is connected, what the latest value is, etc.
if epics.ca.isConnected(self.pv.chid):
Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/fake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Connection(PyDMConnection):
def __init__(self, widget, address, protocol=None, parent=None):
super(Connection, self).__init__(widget, address, protocol, parent)
super().__init__(widget, address, protocol, parent)
self.add_listener(widget)
self.value = address
self.rand = 0
Expand All @@ -22,7 +22,7 @@ def send_connection_state(self, conn):
self.connection_state_signal.emit(conn)

def add_listener(self, widget):
super(Connection, self).add_listener(widget)
super().add_listener(widget)
self.send_connection_state(True)


Expand Down
4 changes: 2 additions & 2 deletions pydm/data_plugins/local_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, channel, address, protocol=None, parent=None):
self._lower_limit = None
self._enum_string = None

super(Connection, self).__init__(channel, address, protocol, parent)
super().__init__(channel, address, protocol, parent)
self._configuration = {}
self.add_listener(channel)
self.send_connection_state(False)
Expand Down Expand Up @@ -330,7 +330,7 @@ def send_connection_state(self, conn):
self.connection_state_signal.emit(conn)

def add_listener(self, channel):
super(Connection, self).add_listener(channel)
super().add_listener(channel)
self._configure_local_plugin(channel)
# send write access == True to the listeners
self.send_access_state()
Expand Down
2 changes: 1 addition & 1 deletion pydm/data_plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PyDMConnection(QObject):
timestamp_signal = Signal(float)

def __init__(self, channel, address, protocol=None, parent=None):
super(PyDMConnection, self).__init__(parent)
super().__init__(parent)
self.protocol = protocol
self.address = address
self.connected = False
Expand Down
4 changes: 2 additions & 2 deletions pydm/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def load_py_file(pyfile, args=None, macros=None):

class Display(QWidget):
def __init__(self, parent=None, args=None, macros=None, ui_filename=None):
super(Display, self).__init__(parent=parent)
super().__init__(parent=parent)
self.ui = None
self.help_window = None
self._ui_filename = ui_filename
Expand Down Expand Up @@ -482,4 +482,4 @@ def setStyleSheet(self, new_stylesheet):
with open(stylesheet_filename) as f:
self._local_style = f.read()
logger.debug("Setting stylesheet to: %s", self._local_style)
super(Display, self).setStyleSheet(self._local_style)
super().setStyleSheet(self._local_style)
4 changes: 2 additions & 2 deletions pydm/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __new__(cls, *args, **kwargs):
def __init__(self, *args, **kwargs):
if self.__initialized:
return
super(ExceptionDispatcher, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.__initialized = True
self.app = QtWidgets.QApplication.instance()
self.app.aboutToQuit.connect(self.requestInterruption)
Expand Down Expand Up @@ -100,7 +100,7 @@ def __new__(cls, *args, **kwargs):
def __init__(self, *args, **kwargs):
if self.__initialized:
return
super(DefaultExceptionNotifier, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.__initialized = True
ExceptionDispatcher().newException.connect(self.receiveException)

Expand Down
Loading