Skip to content

Commit

Permalink
style: Fix duplicate-isinstance-call (SIM101) (OSGeo#4405)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Sep 28, 2024
1 parent 70f3599 commit ae5e4dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
12 changes: 4 additions & 8 deletions gui/wxpython/gmodeler/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ def OnRightClick(self, x, y, keys=0, attachment=0):
popupMenu = Menu()
popupMenu.Append(self.popupID["remove"], _("Remove"))
self.frame.Bind(wx.EVT_MENU, self.OnRemove, id=self.popupID["remove"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelLoop):
if isinstance(shape, (ModelAction, ModelLoop)):
if shape.IsEnabled():
popupMenu.Append(self.popupID["enable"], _("Disable"))
self.frame.Bind(wx.EVT_MENU, self.OnDisable, id=self.popupID["enable"])
else:
popupMenu.Append(self.popupID["enable"], _("Enable"))
self.frame.Bind(wx.EVT_MENU, self.OnEnable, id=self.popupID["enable"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelComment):
if isinstance(shape, (ModelAction, ModelComment)):
popupMenu.AppendSeparator()
if isinstance(shape, ModelAction):
popupMenu.Append(self.popupID["label"], _("Set label"))
self.frame.Bind(wx.EVT_MENU, self.OnSetLabel, id=self.popupID["label"])
if isinstance(shape, ModelAction) or isinstance(shape, ModelComment):
if isinstance(shape, (ModelAction, ModelComment)):
popupMenu.Append(self.popupID["comment"], _("Set comment"))
self.frame.Bind(wx.EVT_MENU, self.OnSetComment, id=self.popupID["comment"])

Expand Down Expand Up @@ -377,11 +377,7 @@ def OnRightClick(self, x, y, keys=0, attachment=0):
if self.GetShape().IsIntermediate():
popupMenu.Enable(self.popupID["display"], False)

if (
isinstance(shape, ModelData)
or isinstance(shape, ModelAction)
or isinstance(shape, ModelLoop)
):
if isinstance(shape, (ModelData, ModelAction, ModelLoop)):
popupMenu.AppendSeparator()
popupMenu.Append(self.popupID["props"], _("Properties"))
self.frame.Bind(wx.EVT_MENU, self.OnProperties, id=self.popupID["props"])
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,7 @@ def _writeItem(self, item, ignoreBlock=True, variables={}):
self._writePythonAction(
item, variables, self.model.GetIntermediateData()[:3]
)
elif isinstance(item, ModelLoop) or isinstance(item, ModelCondition):
elif isinstance(item, (ModelLoop, ModelCondition)):
# substitute condition
cond = item.GetLabel()
for variable in self.model.GetVariables():
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ ignore = [
"S606", # start-process-with-no-shell
"S607", # start-process-with-partial-path
"S608", # hardcoded-sql-expression
"SIM101", # duplicate-isinstance-call
"SIM102", # collapsible-if
"SIM105", # suppressible-exception
"SIM108", # if-else-block-instead-of-if-exp
Expand Down

0 comments on commit ae5e4dd

Please sign in to comment.