Skip to content

Commit

Permalink
safe ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Feb 11, 2024
1 parent b5f70e1 commit 7a79963
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 68 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@
html_logo = "images/dls-logo.svg"
html_favicon = html_logo

numfig = True
numfig = True
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ commands =
[tool.ruff]
src = ["src", "tests"]
line-length = 88
# ignoring line to long for the moment to avoid signficant changes to the code
lint.ignore = [
"E501", # line too long
]
lint.select = [
"B", # flake8-bugbear - https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"C4", # flake8-comprehensions - https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/CSstatus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/env dls-python2.6
# -*- coding: utf-8 -*-

import sys

Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/GlobalStatus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys

from PyQt5.QtCore import QObject, Qt, pyqtSignal, pyqtSlot
Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/axissettings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

from PyQt5.QtWidgets import QDialog, QMessageBox

Expand Down
12 changes: 7 additions & 5 deletions src/dls_pmac_control/commsThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import traceback
from queue import Empty, Queue

from dls_pmaclib.dls_pmacremote import (
PmacEthernetInterface,
PmacSerialInterface,
PPmacSshInterface,
)
from PyQt5.QtCore import QCoreApplication, QEvent

from dls_pmaclib.dls_pmacremote import (PmacEthernetInterface,
PmacSerialInterface, PPmacSshInterface)


class CustomEvent(QEvent):
_data = None
Expand All @@ -20,7 +22,7 @@ def data(self):
return self._data


class CommsThread(object):
class CommsThread:
def __init__(self, parent):
self.parent = parent
self.CSNum = 1
Expand Down Expand Up @@ -159,7 +161,7 @@ def updateFunc(self):
# PowerBrick channels are zero-indexed
cmd = cmd + "BrickLV.Chan[" + str(motorNo - 1) + "].I2tFaultStatus BrickLV.Chan[" + str(motorNo - 1) + "].OverCurrent"
else:
# Add a dummy request to keep the request chunks
# Add a dummy request to keep the request chunks
# the same length (p99 always returns zero)
cmd = cmd + "m" + str(motorNo) + "90 p99"
else:
Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/energise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

import re
import sys
Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/login.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from PyQt5.QtWidgets import QDialog

from dls_pmac_control.ui_formLogin import Ui_Login
Expand Down
30 changes: 19 additions & 11 deletions src/dls_pmac_control/motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,36 @@
from os import path
from queue import Empty

from dls_pmaclib.dls_pmacremote import (
PmacEthernetInterface,
PmacSerialInterface,
PmacTelnetInterface,
PPmacSshInterface,
)
from dls_pmaclib.dls_pmcpreprocessor import ClsPmacParser
from PyQt5.QtCore import QEvent, Qt, pyqtSlot
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import (QApplication, QFileDialog, QLineEdit, QMainWindow,
QMessageBox, QProgressDialog, QTableWidgetItem)

from dls_pmac_control.axissettings import (Axissettingsform,
PpmacAxissettingsform)
from PyQt5.QtWidgets import (
QApplication,
QFileDialog,
QLineEdit,
QMainWindow,
QMessageBox,
QProgressDialog,
QTableWidgetItem,
)

from dls_pmac_control.axissettings import Axissettingsform, PpmacAxissettingsform
from dls_pmac_control.commsThread import CommsThread
from dls_pmac_control.CSstatus import CSStatusForm, PpmacCSStatusForm
from dls_pmac_control.energise import Energiseform
from dls_pmac_control.gather import PmacGatherform
from dls_pmac_control.GlobalStatus import (GlobalStatusForm,
PpmacGlobalStatusForm)
from dls_pmac_control.GlobalStatus import GlobalStatusForm, PpmacGlobalStatusForm
from dls_pmac_control.login import Loginform
from dls_pmac_control.ppmacgather import PpmacGatherform
from dls_pmac_control.status import PpmacStatusform, Statusform
from dls_pmac_control.ui_formControl import Ui_ControlForm
from dls_pmac_control.watches import Watchesform
from dls_pmaclib.dls_pmacremote import (PmacEthernetInterface,
PmacSerialInterface,
PmacTelnetInterface, PPmacSshInterface)
from dls_pmaclib.dls_pmcpreprocessor import ClsPmacParser

from . import __version__

Expand Down
1 change: 0 additions & 1 deletion src/dls_pmac_control/status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

import sys

Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formAxisSettings.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formAxisSettings.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formAxisSettings(object):
class Ui_formAxisSettings:
def setupUi(self, formAxisSettings):
formAxisSettings.setObjectName("formAxisSettings")
formAxisSettings.resize(508, 548)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formCSStatus.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'src/dls_pmac_control/formCSStatus.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formCSStatus(object):
class Ui_formCSStatus:
def setupUi(self, formCSStatus):
formCSStatus.setObjectName("formCSStatus")
formCSStatus.resize(433, 311)
Expand Down
3 changes: 1 addition & 2 deletions src/dls_pmac_control/ui_formControl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formControl.ui'
#
Expand All @@ -9,7 +8,7 @@
from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_ControlForm(object):
class Ui_ControlForm:
def setupUi(self, ControlForm):
ControlForm.setObjectName("ControlForm")
ControlForm.resize(675, 805)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formEnergise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formEnergise.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formEnergise(object):
class Ui_formEnergise:
def setupUi(self, formEnergise):
formEnergise.setObjectName("formEnergise")
formEnergise.resize(192, 252)
Expand Down
3 changes: 1 addition & 2 deletions src/dls_pmac_control/ui_formGather.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formGather.ui'
#
Expand All @@ -12,7 +11,7 @@
from qwt import QwtPlot


class Ui_formGather(object):
class Ui_formGather:
def setupUi(self, formGather):
formGather.setObjectName("formGather")
formGather.resize(608, 429)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formGlobalStatus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formGlobalStatus.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formGlobalStatus(object):
class Ui_formGlobalStatus:
def setupUi(self, formGlobalStatus):
formGlobalStatus.setObjectName("formGlobalStatus")
formGlobalStatus.resize(122, 144)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formLogin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formLogin.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_Login(object):
class Ui_Login:
def setupUi(self, Login):
Login.setObjectName("Login")
Login.resize(314, 145)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formPpmacAxisSettings.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formPpmacAxisSettings.ui'
#
# Created by: PyQt5 UI code generator 5.12.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formPpmacAxisSettings(object):
class Ui_formPpmacAxisSettings:
def setupUi(self, formPpmacAxisSettings):
formPpmacAxisSettings.setObjectName("formPpmacAxisSettings")
formPpmacAxisSettings.resize(580, 688)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formPpmacCSStatus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formPpmacCSStatus.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formPpmacCSStatus(object):
class Ui_formPpmacCSStatus:
def setupUi(self, formCSStatus):
formCSStatus.setObjectName("formCSStatus")
formCSStatus.setGeometry(QtCore.QRect(0, 0, 433, 311))
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formStatus.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formStatus.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formStatus(object):
class Ui_formStatus:
def setupUi(self, formStatus):
formStatus.setObjectName("formStatus")
formStatus.resize(99, 189)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/ui_formWatches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'dls_pmac_control/formWatches.ui'
#
Expand All @@ -8,10 +7,10 @@
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import QtCore, QtWidgets


class Ui_formWatches(object):
class Ui_formWatches:
def setupUi(self, formWatches):
formWatches.setObjectName("formWatches")
formWatches.resize(905, 585)
Expand Down
5 changes: 2 additions & 3 deletions src/dls_pmac_control/watches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-

import re

Expand Down Expand Up @@ -115,7 +114,7 @@ def applyEditWatch(self):
self.updateCurrentWatch()
self.lneEditValue.setText("")
self.panelEditWatch.setEnabled(False)
except (ValueError, IOError) as e:
except (OSError, ValueError) as e:
self.lneEditValue.setText("")
self.panelEditWatch.setEnabled(False)
QMessageBox.information(self, "Cannot change value", str(e))
Expand Down Expand Up @@ -162,7 +161,7 @@ def _sendPMACCommand(self, command):
# Get response from PMAC; the 2nd returned boolean indicates absence of timeout
(s, wasNoTimeout) = self.pmac.sendCommand(command)
if not wasNoTimeout:
raise IOError("Connection to PMAC timed out")
raise OSError("Connection to PMAC timed out")

# Check whether PMAC doesn't reply with an ERRxx type response
matchObject = re.match(r"^\x07(ERR\d+)\r$", s)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_axissettings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import Mock, patch

from mock import Mock, patch
from PyQt5.QtCore import Qt
from PyQt5.QtTest import QTest
from PyQt5.QtWidgets import QMainWindow
Expand Down
2 changes: 1 addition & 1 deletion tests/test_commsthread.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import Mock, patch

from mock import Mock, patch
from PyQt5.QtWidgets import QMainWindow

from dls_pmac_control.commsThread import CommsThread
Expand Down
2 changes: 1 addition & 1 deletion tests/test_csstatus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from os import path
from unittest.mock import Mock, patch

from mock import Mock, patch
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap
from PyQt5.QtTest import QTest
Expand Down
2 changes: 1 addition & 1 deletion tests/test_energise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import Mock, patch

from mock import Mock, patch
from PyQt5.QtWidgets import QCheckBox, QMainWindow

from dls_pmac_control.energise import Energiseform
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gather.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from unittest.mock import Mock, patch

from mock import Mock, patch
from PyQt5.QtCore import QPoint, Qt
from PyQt5.QtTest import QTest
from PyQt5.QtWidgets import QMainWindow
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gatherchannel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import Mock

from mock import Mock
from PyQt5.QtWidgets import QMainWindow
from qwt import QwtPlotCurve

Expand Down
Loading

0 comments on commit 7a79963

Please sign in to comment.