@@ -137,8 +137,8 @@ def unstage(self):
137137 logger .warning ("Still capturing data .... giving up." )
138138 logger .warning (
139139 "Check that the xspress3 is configured to take the right "
140- "number of frames "
141- f"(it is trying to take { self .parent .settings .num_images .get ()} )"
140+ "number of frames (it is trying to take %s)" ,
141+ self .parent .settings .num_images .get ()
142142 )
143143 self .capture .put (0 )
144144 break
@@ -171,7 +171,8 @@ def stage(self):
171171
172172 total_points = self .parent .total_points .get ()
173173 if total_points < 1 :
174- raise RuntimeError ("You must set the total points" )
174+ msg = "You must set the total points"
175+ raise RuntimeError (msg )
175176 spec_per_point = self .parent .spectra_per_point .get ()
176177 total_capture = total_points * spec_per_point
177178
@@ -223,9 +224,8 @@ def stage(self):
223224 )
224225
225226 if not self .file_path_exists .get ():
226- raise OSError (
227- f"Path { self .file_path .get ()} does not exits on IOC!! Please Check"
228- )
227+ msg = f"Path { self .file_path .get ()} does not exits on IOC!! Please Check"
228+ raise OSError (msg )
229229
230230 logger .debug ("Inserting the filestore resource: %s" , self ._fn )
231231 self ._generate_resource ({})
@@ -365,10 +365,7 @@ def __init__(
365365 ** kwargs ,
366366 ):
367367 if read_attrs is None :
368- if use_sum :
369- read_attrs = ["value_sum" ]
370- else :
371- read_attrs = ["value" , "value_sum" ]
368+ read_attrs = ["value_sum" ] if use_sum else ["value" , "value_sum" ]
372369
373370 if configuration_attrs is None :
374371 configuration_attrs = ["ev_low" , "ev_high" , "enable" ]
@@ -464,18 +461,18 @@ def make_rois(rois):
464461 for roi in rois :
465462 attr = f"roi{ roi :02d} "
466463 # cls prefix kwargs
467- defn [attr ] = (Xspress3ROI , f"ROI{ roi } :" , dict ( roi_num = roi ) )
464+ defn [attr ] = (Xspress3ROI , f"ROI{ roi } :" , { " roi_num" : roi } )
468465 # e.g., device.rois.roi01 = Xspress3ROI('ROI1:', roi_num=1)
469466
470467 # AreaDetector NDPluginAttribute information
471468 attr = f"ad_attr{ roi :02d} "
472- defn [attr ] = (Xspress3ROISettings , f"ROI{ roi } :" , dict ( read_attrs = []) )
469+ defn [attr ] = (Xspress3ROISettings , f"ROI{ roi } :" , { " read_attrs" : []} )
473470 # e.g., device.rois.roi01 = Xspress3ROI('ROI1:', roi_num=1)
474471
475472 # TODO: 'roi01' and 'ad_attr_01' have the same prefix and could
476473 # technically be combined. Is this desirable?
477474
478- defn ["num_rois" ] = (Signal , None , dict ( value = len (rois )) )
475+ defn ["num_rois" ] = (Signal , None , { " value" : len (rois )} )
479476 # e.g., device.rois.num_rois.get() => 16
480477 return defn
481478
@@ -518,7 +515,8 @@ def set_roi(self, index, ev_low, ev_high, *, name=None):
518515 roi = index
519516 else :
520517 if index <= 0 :
521- raise ValueError ("ROI index starts from 1" )
518+ msg = "ROI index starts from 1"
519+ raise ValueError (msg )
522520 roi = list (self .all_rois )[index - 1 ]
523521
524522 roi .configure (ev_low , ev_high )
@@ -563,11 +561,11 @@ def __init__(
563561 name = None ,
564562 parent = None ,
565563 # to remove?
566- file_path = "" ,
567- ioc_file_path = "" ,
568- default_channels = None ,
569- channel_prefix = None ,
570- roi_sums = False ,
564+ file_path = "" , # noqa : ARG002
565+ ioc_file_path = "" , # noqa : ARG002
566+ default_channels = None , # noqa : ARG002
567+ channel_prefix = None , # noqa : ARG002
568+ roi_sums = False , # noqa : ARG002
571569 # to remove?
572570 ** kwargs ,
573571 ):
@@ -607,8 +605,8 @@ def channels(self):
607605
608606 @property
609607 def all_rois (self ):
610- for ch_num , channel in self ._channels .items ():
611- for roi in channel .all_rois :
608+ for _ , channel in self ._channels .items ():
609+ for roi in channel .all_rois : # noqa : UP028
612610 yield roi
613611
614612 @property
@@ -617,7 +615,7 @@ def enabled_rois(self):
617615 if roi .enable .get ():
618616 yield roi
619617
620- def read_hdf5 (self , fn , * , rois = None , max_retries = 2 ):
618+ def read_hdf5 (self , fn , * , rois = None , max_retries = 2 ): # noqa : ARG002
621619 """Read ROI data from an HDF5 file using the current ROI configuration
622620
623621 Parameters
@@ -631,10 +629,7 @@ def read_hdf5(self, fn, *, rois=None, max_retries=2):
631629 rois = self .enabled_rois
632630
633631 num_points = self .settings .num_images .get ()
634- if isinstance (fn , h5py .File ):
635- hdf = fn
636- else :
637- hdf = h5py .File (fn , "r" )
632+ hdf = fn if isinstance (fn , h5py .File ) else h5py .File (fn , "r" )
638633
639634 RoiTuple = Xspress3ROI .get_device_tuple ()
640635
@@ -689,7 +684,7 @@ def unstage(self):
689684 self ._status = None
690685 return ret
691686
692- def _acquire_changed (self , value = None , old_value = None , ** kwargs ):
687+ def _acquire_changed (self , value = None , old_value = None , ** kwargs ): # noqa : ARG002
693688 "This is called when the 'acquire' signal changes."
694689 if self ._status is None :
695690 return
@@ -699,7 +694,8 @@ def _acquire_changed(self, value=None, old_value=None, **kwargs):
699694
700695 def trigger (self ):
701696 if self ._staged != Staged .yes :
702- raise RuntimeError ("not staged" )
697+ msg = "not staged"
698+ raise RuntimeError (msg )
703699
704700 self ._status = DeviceStatus (self )
705701 self ._acquisition_signal .put (1 , wait = False )
0 commit comments