From 48c8eaa63fa475e261177701c62102a794d89e77 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Sun, 11 Feb 2024 20:58:54 +0000 Subject: [PATCH] manual ruff fixes --- src/dls_pmac_control/gather.py | 8 ++------ src/dls_pmac_control/motor.py | 22 ++++++++++++++-------- src/dls_pmac_control/watches.py | 13 ++++++------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/dls_pmac_control/gather.py b/src/dls_pmac_control/gather.py index 41ca8ead..f1bcd205 100644 --- a/src/dls_pmac_control/gather.py +++ b/src/dls_pmac_control/gather.py @@ -187,7 +187,6 @@ def gatherConfig(self): return True def gatherSetup(self, numberOfSamples=1): - # Run through the bitmasks i5050 and i5051 to see which of the # 48 channels should be sampled. bitOffset = 1 @@ -223,10 +222,8 @@ def gatherSetup(self, numberOfSamples=1): # Run through all the channels to sample from self.oddNumberOfWords = False - for chIndex, ch in enumerate(self.lstChannels): - + for _, ch in enumerate(self.lstChannels): # Get the data info - # print "channel: %d"%chIndex ch.getDataInfo() # Figure out the data width and odd/even number of data words @@ -312,7 +309,6 @@ def parseData(self, lstDataStrings): ch.rawToScaled() def plotData(self): - # xAxisData = range(self.numberOfSamples) for _chIndex, ch in enumerate(self.lstChannels): data = ch.scaledData @@ -430,7 +426,7 @@ def saveClicked(self): QMessageBox.information( self, "Error", - "Could not open file for writing." + "Could not open file for writing.", # buttons=1, # p_str_1="OK", ) diff --git a/src/dls_pmac_control/motor.py b/src/dls_pmac_control/motor.py index f5354354..67ffe1d3 100755 --- a/src/dls_pmac_control/motor.py +++ b/src/dls_pmac_control/motor.py @@ -632,7 +632,6 @@ def addToTxtShell(self, command, retStr=None, chkShowAll=True): # Called when an event comes out of the polling thread # and the jog ribbon. def updateMotors(self): - under_voltage = False over_voltage = False over_temperature = False @@ -647,7 +646,7 @@ def updateMotors(self): try: motorRow = value[6] # check for special cases - if type(motorRow) == str: + if isinstance(motorRow, str): if isinstance(self.pmac, PPmacSshInterface): if motorRow == "G": self.PpmacGlobalStatusScreen.updateStatus( @@ -702,14 +701,13 @@ def updateMotors(self): over_current = False if motorRow < 8: - if isinstance(self.pmac, PPmacSshInterface): if int(value[4]) > 0: i2t_fault = True if int(value[5]) > 0: over_current = True elif isinstance(self.pmac, PmacEthernetInterface): - amp_status = ((int(value[4])&448)>>6) + amp_status = (int(value[4]) & 448) >> 6 if amp_status == 5: i2t_fault = True elif amp_status == 6: @@ -732,13 +730,21 @@ def updateMotors(self): if isinstance(self.pmac, PPmacSshInterface): loLim = bool(statusWord & 0x2000000000000000) # MinusLimit hiLim = bool(statusWord & 0x1000000000000000) # PlusLimit - loLimSoft = bool(statusWord & 0x0080000000000000) # SoftMinusLimit - hiLimSoft = bool(statusWord & 0x0040000000000000) # SoftPlusLimit + loLimSoft = bool( + statusWord & 0x0080000000000000 + ) # SoftMinusLimit + hiLimSoft = bool( + statusWord & 0x0040000000000000 + ) # SoftPlusLimit # define high and low limits for pmac else: - loLim = bool(statusWord & 0x400000000000) # negative end limit set - hiLim = bool(statusWord & 0x200000000000) # positive end limit set + loLim = bool( + statusWord & 0x400000000000 + ) # negative end limit set + hiLim = bool( + statusWord & 0x200000000000 + ) # positive end limit set loLimSoft = False hiLimSoft = False diff --git a/src/dls_pmac_control/watches.py b/src/dls_pmac_control/watches.py index db470d97..2eb82668 100644 --- a/src/dls_pmac_control/watches.py +++ b/src/dls_pmac_control/watches.py @@ -1,4 +1,3 @@ - import re from PyQt5.QtWidgets import QDialog, QMessageBox, QTableWidgetItem @@ -23,7 +22,7 @@ def __init__(self, parent): def addWatch(self): varName = str(self.lneVariableName.text()) try: - assert type(varName) is str + assert isinstance(varName, str) varName = varName.lower() if varName in unsafeCommands: raise ValueError("%s is an unsafe command" % varName) @@ -50,8 +49,8 @@ def getWatch(self, varName): varName = varName.lower() try: watch = self._watches[varName] - except KeyError: - raise ValueError('There is no watch for variable "%s"' % varName) + except KeyError as e: + raise ValueError(msg='There is no watch for variable "%s"' % varName) from e return watch def updateWatch(self, row): @@ -70,13 +69,13 @@ def removeWatch(self): row = self.table.currentRow() if row == -1: return None - assert type(row) is int + assert isinstance(row, int) varName = self.table.item(row, 0).text() try: del self._watches[varName] self.parent.commsThread.remove_watch(varName) - except KeyError: - raise ValueError('There is no watch for variable "%s"' % varName) + except KeyError as e: + raise ValueError(msg='There is no watch for variable "%s"' % varName) from e try: self.table.removeRow(row) # self.updateEditWatchPanel()