Skip to content

Commit

Permalink
style: Fix if-else-block-instead-of-dict-get (SIM401) (#4558)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Oct 20, 2024
1 parent 884fc6f commit 32723e0
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/iclass/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def ActivateSecondMap(self, event=None):

def GetMapToolbar(self):
"""Returns toolbar with zooming tools"""
return self.toolbars["iClassMap"] if "iClassMap" in self.toolbars else None
return self.toolbars.get("iClassMap", None)

def GetClassColor(self, cat):
"""Get class color as string
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapdisp/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ def SetProperties(

def GetMapToolbar(self):
"""Returns toolbar with zooming tools"""
return self.toolbars["map"] if "map" in self.toolbars else None
return self.toolbars.get("map", None)

def GetDialog(self, name):
"""Get selected dialog if exist"""
Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/vnet/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,7 @@ def OnAnalysisChanged(self, event):
attrCols = an_props["cmdParams"]["cols"]

for col in attrCols.keys():
if "inputField" in attrCols[col]:
colInptF = attrCols[col]["inputField"]
else:
colInptF = col
colInptF = attrCols[col].get("inputField", col)

if col in skip:
continue
Expand Down
5 changes: 1 addition & 4 deletions gui/wxpython/vnet/vnet_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,7 @@ def _setInputParams(self, analysis, params, flags):

inParams = []
for col, v in self.data.GetAnalysisProperties()["cmdParams"]["cols"].items():
if "inputField" in v:
colInptF = v["inputField"]
else:
colInptF = col
colInptF = v.get("inputField", col)

inParams.append(col + "=" + params[colInptF])

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ ignore = [
"SIM116", # if-else-block-instead-of-dict-lookup
"SIM118", # in-dict-keys
"SIM223", # expr-and-false
"SIM401", # if-else-block-instead-of-dict-get
"SLF001", # private-member-access
"TRY002", # raise-vanilla-class
"TRY003", # raise-vanilla-args
Expand Down
5 changes: 1 addition & 4 deletions python/grass/temporal/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,7 @@ def register_maps_in_space_time_dataset(
end = row["end"]

# Use the semantic label from file
if "semantic_label" in row:
semantic_label = row["semantic_label"]
else:
semantic_label = None
semantic_label = row.get("semantic_label", None)

is_in_db = map_object.is_in_db(dbif, mapset)

Expand Down
5 changes: 1 addition & 4 deletions scripts/i.pansharpen/i.pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,7 @@ def matchhist(original, target, matched):
)

for n in range(256):
if str(n) in stats_dict:
num_cells = stats_dict[str(n)]
else:
num_cells = 0
num_cells = stats_dict.get(str(n), 0)

cum_cells += num_cells

Expand Down

0 comments on commit 32723e0

Please sign in to comment.