Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Fix duplicate-isinstance-call (SIM101) #4405

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -246,7 +246,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
Loading