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 unnecessary-list-comprehension-dict (C404) #4454

Merged
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ ignore = [
"B904", # raise-without-from-inside-except
"B909", # loop-iterator-mutation
"BLE001", # blind-except
"C404", # unnecessary-list-comprehension-dict
"C414", # unnecessary-double-cast-or-process
"C416", # unnecessary-comprehension
"COM812", # missing-trailing-comma
Expand Down
2 changes: 1 addition & 1 deletion python/grass/pydispatch/robustapply.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ def robustApply(receiver, *arguments, **named):
)
# fc does not have a **kwds type parameter, therefore
# remove unacceptable arguments.
named = dict([(k, v) for k, v in named.items() if k in acceptable])
named = {k: v for k, v in named.items() if k in acceptable}
return receiver(*arguments, **named)
6 changes: 2 additions & 4 deletions python/grass/pygrass/modules/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ def read_gisrc(gisrc):
True
"""
with open(gisrc) as gfile:
gis = dict(
[(k.strip(), v.strip()) for k, v in [row.split(":", 1) for row in gfile]]
)
gis = {k.strip(): v.strip() for k, v in [row.split(":", 1) for row in gfile]}
return gis["MAPSET"], gis["LOCATION_NAME"], gis["GISDBASE"]


Expand Down Expand Up @@ -603,7 +601,7 @@ def get_works(self):
indx = row * cols + col
inms[key] = "%s@%s" % (self.inlist[key][indx], self.mset.name)
# set the computational region, prepare the region parameters
bbox = dict([(k[0], str(v)) for k, v in box.items()[:-2]])
bbox = {k[0]: str(v) for k, v in box.items()[:-2]}
bbox["nsres"] = "%f" % reg.nsres
bbox["ewres"] = "%f" % reg.ewres
new_mset = (
Expand Down
9 changes: 3 additions & 6 deletions python/grass/pygrass/modules/interface/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ def get_env():
if gisrc is None:
raise RuntimeError("You are not in a GRASS session, GISRC not found.")
with open(gisrc) as grc:
return dict(
[
(k.strip(), v.strip())
for k, v in [row.split(":", 1) for row in grc if row]
]
)
return {
k.strip(): v.strip() for k, v in [row.split(":", 1) for row in grc if row]
}


def get_debug_level():
Expand Down
2 changes: 1 addition & 1 deletion utils/g.html2man/ghtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@


def setify(d):
return dict([(key, frozenset(val)) for key, val in d.items()])
return {key: frozenset(val) for key, val in d.items()}


def omit(allowed, tags):
Expand Down
Loading