From 7ab4fde67349414bc0a9d757ed120dddafcb2ad1 Mon Sep 17 00:00:00 2001 From: Arohan Ajit Date: Tue, 12 Nov 2024 20:49:55 -0500 Subject: [PATCH] wxGUI: Fixed unused variable and bare 'except' in frame.py (#4655) --- .flake8 | 1 - gui/wxpython/tplot/frame.py | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.flake8 b/.flake8 index fa0d553e0a7..84cc7d7e353 100644 --- a/.flake8 +++ b/.flake8 @@ -27,7 +27,6 @@ per-file-ignores = gui/wxpython/psmap/*: E501 gui/wxpython/vdigit/*: F841, E722, F405, F403 gui/wxpython/animation/g.gui.animation.py: E501 - gui/wxpython/tplot/frame.py: F841, E722 gui/wxpython/tplot/g.gui.tplot.py: E501 gui/wxpython/iclass/frame.py: F405, F403 gui/wxpython/iclass/g.gui.iclass.py: E501 diff --git a/gui/wxpython/tplot/frame.py b/gui/wxpython/tplot/frame.py index db798081c51..71705cc0160 100755 --- a/gui/wxpython/tplot/frame.py +++ b/gui/wxpython/tplot/frame.py @@ -212,7 +212,7 @@ def _layout(self): self.coorval = gselect.CoordinatesSelect( parent=self.controlPanelRaster, giface=self._giface ) - except: + except NotImplementedError: self.coorval = TextCtrl( parent=self.controlPanelRaster, id=wx.ID_ANY, @@ -281,7 +281,7 @@ def _layout(self): self.cats = gselect.VectorCategorySelect( parent=self.controlPanelVector, giface=self._giface ) - except: + except NotImplementedError: self.cats = TextCtrl( parent=self.controlPanelVector, id=wx.ID_ANY, @@ -1029,10 +1029,10 @@ def OnRedraw(self, event=None): try: getcoors = self.coorval.coordsField.GetValue() - except: + except AttributeError: try: getcoors = self.coorval.GetValue() - except: + except AttributeError: getcoors = None if getcoors and getcoors != "": try: @@ -1257,7 +1257,7 @@ def SetDatasets( return try: self.coorval.coordsField.SetValue(",".join(coors)) - except: + except AttributeError: self.coorval.SetValue(",".join(coors)) if self.datasetsV: vdatas = ",".join(f"{x[0]}@{x[1]}" for x in self.datasetsV) @@ -1448,7 +1448,7 @@ def __call__(self, event): """Intended to be called through "mpl_connect".""" # Rather than trying to interpolate, just display the clicked coords # This will only be called if it's within "tolerance", anyway. - x, y = event.mouseevent.xdata, event.mouseevent.ydata + x = event.mouseevent.xdata annotation = self.annotations[event.artist.axes] if x is not None: if not self.display_all: @@ -1460,7 +1460,7 @@ def __call__(self, event): for a in event.artist.get_xdata(): try: d = self.convert(a) - except: + except (IndexError, ValueError): d = a xData.append(d) x = xData[np.argmin(abs(xData - x))]