Skip to content

Commit e3a4b3e

Browse files
MNT: do not pass the default arguments of super()
In Python 3, the default arguments of the builtin super() are the current class and instance: https://docs.python.org/3/library/functions.html#super
1 parent bd1a896 commit e3a4b3e

File tree

15 files changed

+50
-50
lines changed

15 files changed

+50
-50
lines changed

niworkflows/engine/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, name, base_dir=None):
4343
path to workflow storage
4444
4545
"""
46-
super(LiterateWorkflow, self).__init__(name, base_dir)
46+
super().__init__(name, base_dir)
4747
self.__desc__ = None
4848
self.__postdesc__ = None
4949

niworkflows/interfaces/bids.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class BIDSDataGrabber(SimpleInterface):
253253
def __init__(self, *args, **kwargs):
254254
anat_only = kwargs.pop("anat_only")
255255
anat_derivatives = kwargs.pop("anat_derivatives", None)
256-
super(BIDSDataGrabber, self).__init__(*args, **kwargs)
256+
super().__init__(*args, **kwargs)
257257
if anat_only is not None:
258258
self._require_funcs = not anat_only
259259
self._require_t1w = anat_derivatives is None
@@ -820,12 +820,12 @@ class ReadSidecarJSON(SimpleInterface):
820820
def __init__(self, fields=None, undef_fields=False, **inputs):
821821
from bids.utils import listify
822822

823-
super(ReadSidecarJSON, self).__init__(**inputs)
823+
super().__init__(**inputs)
824824
self._fields = listify(fields or [])
825825
self._undef_fields = undef_fields
826826

827827
def _outputs(self):
828-
base = super(ReadSidecarJSON, self)._outputs()
828+
base = super()._outputs()
829829
if self._fields:
830830
base = add_traits(base, self._fields)
831831
return base

niworkflows/interfaces/fixes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class FixHeaderApplyTransforms(ApplyTransforms):
6161

6262
def _run_interface(self, runtime, correct_return_codes=(0,)):
6363
# Run normally
64-
runtime = super(FixHeaderApplyTransforms, self)._run_interface(
64+
runtime = super()._run_interface(
6565
runtime, correct_return_codes
6666
)
6767

@@ -100,7 +100,7 @@ class FixHeaderRegistration(Registration):
100100

101101
def _run_interface(self, runtime, correct_return_codes=(0,)):
102102
# Run normally
103-
runtime = super(FixHeaderRegistration, self)._run_interface(
103+
runtime = super()._run_interface(
104104
runtime, correct_return_codes
105105
)
106106

@@ -143,12 +143,12 @@ def __init__(self, *args, **kwargs):
143143
"""Add a private property to keep the path to the right input."""
144144
self._input_image = None
145145
self._negative_values = False
146-
super(FixN4BiasFieldCorrection, self).__init__(*args, **kwargs)
146+
super().__init__(*args, **kwargs)
147147

148148
def _format_arg(self, name, trait_spec, value):
149149
if name == "input_image":
150150
return trait_spec.argstr % self._input_image
151-
return super(FixN4BiasFieldCorrection, self)._format_arg(
151+
return super()._format_arg(
152152
name, trait_spec, value
153153
)
154154

@@ -166,9 +166,9 @@ def _parse_inputs(self, skip=None):
166166
newnii.to_filename(self._input_image)
167167
self._negative_values = True
168168

169-
return super(FixN4BiasFieldCorrection, self)._parse_inputs(skip=skip)
169+
return super()._parse_inputs(skip=skip)
170170

171171
def _list_outputs(self):
172-
outputs = super(FixN4BiasFieldCorrection, self)._list_outputs()
172+
outputs = super()._list_outputs()
173173
outputs["negative_values"] = self._negative_values
174174
return outputs

niworkflows/interfaces/freesurfer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ def _num_vols(self):
8080
def cmdline(self):
8181
if self._num_vols() == 1:
8282
return "echo Only one time point!"
83-
return super(StructuralReference, self).cmdline
83+
return super().cmdline
8484

8585
def _list_outputs(self):
86-
outputs = super(StructuralReference, self)._list_outputs()
86+
outputs = super()._list_outputs()
8787
if self._num_vols() == 1:
8888
in_file = self.inputs.in_files[0]
8989
outputs["out_file"] = in_file
@@ -117,7 +117,7 @@ class MakeMidthickness(fs.MRIsExpand):
117117

118118
@property
119119
def cmdline(self):
120-
cmd = super(MakeMidthickness, self).cmdline
120+
cmd = super().cmdline
121121
if not isdefined(self.inputs.graymid) or len(self.inputs.graymid) < 1:
122122
return cmd
123123

@@ -247,7 +247,7 @@ def _post_run_hook(self, runtime):
247247

248248
fix_lta_length(lta_file)
249249

250-
runtime = super(TruncateLTA, self)._post_run_hook(runtime)
250+
runtime = super()._post_run_hook(runtime)
251251
return runtime
252252

253253

niworkflows/interfaces/header.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ def __init__(self, fields=None, **inputs):
6767
if isinstance(self._fields, str):
6868
self._fields = [self._fields]
6969

70-
super(CopyXForm, self).__init__(**inputs)
70+
super().__init__(**inputs)
7171

7272
add_traits(self.inputs, self._fields)
7373
for f in set(self._fields).intersection(list(inputs.keys())):
7474
setattr(self.inputs, f, inputs[f])
7575

7676
def _outputs(self):
77-
base = super(CopyXForm, self)._outputs()
77+
base = super()._outputs()
7878
if self._fields:
7979
fields = self._fields.copy()
8080
if "in_file" in fields:

niworkflows/interfaces/nilearn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ def _run_interface(self, runtime):
241241
self._mask_file = os.path.join(runtime.cwd, "mask_file.nii.gz")
242242

243243
runtime.returncode = 0
244-
return super(ComputeEPIMask, self)._run_interface(runtime)
244+
return super()._run_interface(runtime)
245245

246246
def _list_outputs(self):
247-
outputs = super(ComputeEPIMask, self)._list_outputs()
247+
outputs = super()._list_outputs()
248248
outputs["mask_file"] = self._mask_file
249249
return outputs
250250

@@ -261,7 +261,7 @@ def _post_run_hook(self, runtime):
261261
self._mask_file,
262262
)
263263

264-
return super(ComputeEPIMask, self)._post_run_hook(runtime)
264+
return super()._post_run_hook(runtime)
265265

266266

267267
def _enhance_t2_contrast(in_file, newpath=None, offset=0.5):

niworkflows/interfaces/norm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __init__(self, **inputs):
148148
self._reference_image = None
149149
self.retry = 1
150150
self.terminal_output = "file"
151-
super(SpatialNormalization, self).__init__(**inputs)
151+
super().__init__(**inputs)
152152

153153
def _get_settings(self):
154154
"""

niworkflows/interfaces/patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _run_interface(self, runtime):
4040
failures = 0
4141
while True:
4242
try:
43-
runtime = super(RobustACompCor, self)._run_interface(runtime)
43+
runtime = super()._run_interface(runtime)
4444
break
4545
except LinAlgError:
4646
failures += 1
@@ -63,7 +63,7 @@ def _run_interface(self, runtime):
6363
failures = 0
6464
while True:
6565
try:
66-
runtime = super(RobustTCompCor, self)._run_interface(runtime)
66+
runtime = super()._run_interface(runtime)
6767
break
6868
except LinAlgError:
6969
failures += 1

niworkflows/interfaces/reportlets/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class ReportingInterface(reporting.ReportCapableInterface):
189189
output_spec = reporting.ReportCapableOutputSpec
190190

191191
def __init__(self, generate_report=True, **kwargs):
192-
super(ReportingInterface, self).__init__(
192+
super().__init__(
193193
generate_report=generate_report, **kwargs
194194
)
195195

niworkflows/interfaces/reportlets/masks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _run_interface(self, runtime):
5757
if self.generate_report:
5858
self.inputs.mask = True
5959

60-
return super(BETRPT, self)._run_interface(runtime)
60+
return super()._run_interface(runtime)
6161

6262
def _post_run_hook(self, runtime):
6363
"""generates a report showing slices from each axis of an arbitrary
@@ -74,7 +74,7 @@ def _post_run_hook(self, runtime):
7474
self._mask_file,
7575
)
7676

77-
return super(BETRPT, self)._post_run_hook(runtime)
77+
return super()._post_run_hook(runtime)
7878

7979

8080
class _BrainExtractionInputSpecRPT(
@@ -117,7 +117,7 @@ def _post_run_hook(self, runtime):
117117
self._mask_file,
118118
)
119119

120-
return super(BrainExtractionRPT, self)._post_run_hook(runtime)
120+
return super()._post_run_hook(runtime)
121121

122122

123123
class _ACompCorInputSpecRPT(nrb._SVGReportCapableInputSpec, confounds.CompCorInputSpec):
@@ -153,7 +153,7 @@ def _post_run_hook(self, runtime):
153153
self._mask_file,
154154
)
155155

156-
return super(ACompCorRPT, self)._post_run_hook(runtime)
156+
return super()._post_run_hook(runtime)
157157

158158

159159
class _TCompCorInputSpecRPT(
@@ -195,7 +195,7 @@ def _post_run_hook(self, runtime):
195195
self.aggregate_outputs(runtime=runtime).high_variance_masks,
196196
)
197197

198-
return super(TCompCorRPT, self)._post_run_hook(runtime)
198+
return super()._post_run_hook(runtime)
199199

200200

201201
class _SimpleShowMaskInputSpec(nrb._SVGReportCapableInputSpec):
@@ -212,7 +212,7 @@ def _post_run_hook(self, runtime):
212212
self._seg_files = [self.inputs.mask_file]
213213
self._masked = True
214214

215-
return super(SimpleShowMaskRPT, self)._post_run_hook(runtime)
215+
return super()._post_run_hook(runtime)
216216

217217

218218
class _ROIsPlotInputSpecRPT(nrb._SVGReportCapableInputSpec):

0 commit comments

Comments
 (0)