Skip to content

Commit 7af729f

Browse files
STY: Apply ruff/Perflint rule PERF403
PERF403 Use a dictionary comprehension instead of a for-loop
1 parent aa1984e commit 7af729f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nipype/interfaces/io.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,16 +2716,14 @@ class JSONFileGrabber(IOBase):
27162716
def _list_outputs(self):
27172717
import simplejson
27182718

2719-
outputs = {}
27202719
if isdefined(self.inputs.in_file):
27212720
with open(self.inputs.in_file) as f:
2722-
data = simplejson.load(f)
2721+
outputs = simplejson.load(f)
27232722

2724-
if not isinstance(data, dict):
2723+
if not isinstance(outputs, dict):
27252724
raise RuntimeError("JSON input has no dictionary structure")
2726-
2727-
for key, value in list(data.items()):
2728-
outputs[key] = value
2725+
else:
2726+
outputs = {}
27292727

27302728
if isdefined(self.inputs.defaults):
27312729
defaults = self.inputs.defaults

0 commit comments

Comments
 (0)