Skip to content

Commit

Permalink
STY: Apply ruff/Perflint rule PERF403
Browse files Browse the repository at this point in the history
PERF403 Use a dictionary comprehension instead of a for-loop
  • Loading branch information
DimitriPapadopoulos committed Sep 22, 2024
1 parent aa1984e commit 7af729f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2716,16 +2716,14 @@ class JSONFileGrabber(IOBase):
def _list_outputs(self):
import simplejson

outputs = {}
if isdefined(self.inputs.in_file):
with open(self.inputs.in_file) as f:
data = simplejson.load(f)
outputs = simplejson.load(f)

Check warning on line 2721 in nipype/interfaces/io.py

View check run for this annotation

Codecov / codecov/patch

nipype/interfaces/io.py#L2721

Added line #L2721 was not covered by tests

if not isinstance(data, dict):
if not isinstance(outputs, dict):
raise RuntimeError("JSON input has no dictionary structure")

for key, value in list(data.items()):
outputs[key] = value
else:
outputs = {}

Check warning on line 2726 in nipype/interfaces/io.py

View check run for this annotation

Codecov / codecov/patch

nipype/interfaces/io.py#L2726

Added line #L2726 was not covered by tests

if isdefined(self.inputs.defaults):
defaults = self.inputs.defaults
Expand Down

0 comments on commit 7af729f

Please sign in to comment.