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 Oct 5, 2024
1 parent 5c02815 commit b7da9dc
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 @@ -2717,16 +2717,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)

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 = {}

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

0 comments on commit b7da9dc

Please sign in to comment.