Skip to content

Commit

Permalink
Simplify super() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Nov 19, 2023
1 parent a601caf commit b8f571a
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 95 deletions.
4 changes: 1 addition & 3 deletions capsul/pipeline/custom_nodes/cv_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def __init__(self, pipeline, name, input_type=None):
in_fields.append({"name": tr, "optional": True})
for tr in out_fieldsl:
out_fields.append({"name": tr, "optional": True})
super(CrossValidationFoldNode, self).__init__(
None, pipeline, name, in_fields, out_fields
)
super().__init__(None, pipeline, name, in_fields, out_fields)
if input_type:
ptype = input_type
else:
Expand Down
4 changes: 1 addition & 3 deletions capsul/pipeline/custom_nodes/loo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def __init__(
in_fields.append({"name": tr, "optional": True})
for tr in out_fieldsl:
out_fields.append({"name": tr, "optional": True})
super(LeaveOneOutNode, self).__init__(
None, pipeline, name, in_fields, out_fields
)
super().__init__(None, pipeline, name, in_fields, out_fields)
if input_type:
ptype = input_type
else:
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/custom_nodes/map_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(

for tr in input_names:
in_fields.append({"name": tr, "optional": False})
super(MapNode, self).__init__(None, pipeline, name, in_fields, out_fields)
super().__init__(None, pipeline, name, in_fields, out_fields)

for tr, ptype in zip(input_names, ptypes):
self.add_field(tr, list[ptype], output=False, default_factory=list)
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/custom_nodes/reduce_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(

for tr in output_names:
out_fields.append({"name": tr, "optional": False})
super(ReduceNode, self).__init__(None, pipeline, name, in_fields, out_fields)
super().__init__(None, pipeline, name, in_fields, out_fields)

for tr, ptype in zip(output_names, ptypes):
self.add_field(
Expand Down
4 changes: 1 addition & 3 deletions capsul/pipeline/custom_nodes/strcat_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def __init__(
node_inputs.append(
{"name": concat_plug, "optional": concat_plug in make_optional}
)
super(StrCatNode, self).__init__(
None, pipeline, name, node_inputs, node_outputs
)
super().__init__(None, pipeline, name, node_inputs, node_outputs)
self._concat_sequence = params
self._concat_plug = concat_plug
self.add_parameters(param_types)
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/custom_nodes/strconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, pipeline, name, input_type=None):
in_fields.append({"name": tr, "optional": True})
for tr in out_fieldsl:
out_fields.append({"name": tr, "optional": True})
super(StrConvNode, self).__init__(None, pipeline, name, in_fields, out_fields)
super().__init__(None, pipeline, name, in_fields, out_fields)
if input_type:
ptype = input_type
else:
Expand Down
8 changes: 3 additions & 5 deletions capsul/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def __init__(self, autoexport_nodes_parameters=None, **kwargs):
raise TypeError("No definition string given to Pipeline constructor")

# Inheritance
super(Pipeline, self).__init__(**kwargs)
super(Pipeline, self).add_field(
super().__init__(**kwargs)
super().add_field(
"nodes_activation", Controller, hidden=self.hide_nodes_activation
)

Expand Down Expand Up @@ -2319,9 +2319,7 @@ def check_requirements(self, environment="global", message_list=None):
A pipeline will return a list of unique configuration values.
"""
# start with pipeline-level requirements
conf = super(Pipeline, self).check_requirements(
environment, message_list=message_list
)
conf = super().check_requirements(environment, message_list=message_list)
if conf is None:
return None
confs = []
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/pipeline_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def _any_attribute_changed(self, new, old, name):

def __setstate__(self, state):
self.__block_output_propagation = True
super(Switch, self).__setstate__(state)
super().__setstate__(state)

def get_connections_through(self, plug_name, single=False):
if not self.activated or not self.enabled:
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/process_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, definition, process, iterative_parameters, context_name=None)
# Avoid circular import
from capsul.api import executable

super(ProcessIteration, self).__init__(definition=definition)
super().__init__(definition=definition)
self.process = executable(process)
if context_name is not None:
self.process.context_name = context_name
Expand Down
4 changes: 1 addition & 3 deletions capsul/pipeline/test/test_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition):
super(DummyProcess, self).__init__(
"capsul.pipeline.test.test_activation.DummyProcess"
)
super().__init__("capsul.pipeline.test.test_activation.DummyProcess")

# inputs
self.add_field("input_image", File, optional=False)
Expand Down
4 changes: 1 addition & 3 deletions capsul/pipeline/test/test_double_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition=None):
super(DummyProcess, self).__init__(
"capsul.pipeline.test.test_double_switch.DummyProcess"
)
super().__init__("capsul.pipeline.test.test_double_switch.DummyProcess")

# inputs
self.add_field("input_image", str, optional=False)
Expand Down
4 changes: 1 addition & 3 deletions capsul/pipeline/test/test_optional_output_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition=None):
super(DummyProcess, self).__init__(
"capsul.pipeline.test.test_optional_output_switch"
)
super().__init__("capsul.pipeline.test.test_optional_output_switch")

# inputs
self.add_field("input_image", File, optional=False)
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/test/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DummyProcess(Process):
def __init__(self, definition=None):
if definition is None:
definition = "capsul.pipeline.test.test_pipeline.DummyProcess"
super(DummyProcess, self).__init__(definition)
super().__init__(definition)

# inputs
self.add_field("input_image", File, optional=False)
Expand Down
4 changes: 2 additions & 2 deletions capsul/pipeline/test/test_pipeline_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition):
super(DummyProcess, self).__init__(definition)
super().__init__(definition)

# inputs
self.add_field("input", File, optional=False)
Expand All @@ -36,7 +36,7 @@ class DummyProcessSPM(DummyProcess):

class DummyListProcess(Process):
def __init__(self, definition):
super(DummyListProcess, self).__init__(definition)
super().__init__(definition)

# inputs
self.add_field("inputs", list[File], optional=False)
Expand Down
2 changes: 1 addition & 1 deletion capsul/pipeline/test/test_switch_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition=None):
super(DummyProcess, self).__init__("capsul.pipeline.test.test_switch_pipeline")
super().__init__("capsul.pipeline.test.test_switch_pipeline")

# inputs
self.add_field("input_image", str, optional=False)
Expand Down
16 changes: 4 additions & 12 deletions capsul/pipeline/test/test_switch_subpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ class DummyProcess(Process):
"""Dummy Test Process"""

def __init__(self, definition=None):
super(DummyProcess, self).__init__(
"capsul.pipeline.test.test_switch_subpipeline.DummyProcess"
)
super().__init__("capsul.pipeline.test.test_switch_subpipeline.DummyProcess")

# inputs
self.add_field("input_image", str, optional=False)
Expand All @@ -31,9 +29,7 @@ class DummyProcess1_1(Process):
"""Dummy Test Process with 1 input and one output"""

def __init__(self, definition=None):
super(DummyProcess1_1, self).__init__(
"capsul.pipeline.test.test_switch_subpipeline.DummyProcess1_1"
)
super().__init__("capsul.pipeline.test.test_switch_subpipeline.DummyProcess1_1")

# inputs
self.add_field("input", str, optional=False)
Expand All @@ -49,9 +45,7 @@ class DummyProcess2_1(Process):
"""Dummy Test Process with 2 inputs and one output"""

def __init__(self, definition=None):
super(DummyProcess2_1, self).__init__(
"capsul.pipeline.test.test_switch_subpipeline.DummyProcess2_1"
)
super().__init__("capsul.pipeline.test.test_switch_subpipeline.DummyProcess2_1")

# inputs
self.add_field("input1", str, optional=False)
Expand All @@ -68,9 +62,7 @@ class DummyProcess4_1(Process):
"""Dummy Test Process with 4 inputs and one output"""

def __init__(self, definition=None):
super(DummyProcess4_1, self).__init__(
"capsul.pipeline.test.test_switch_subpipeline.DummyProcess4_1"
)
super().__init__("capsul.pipeline.test.test_switch_subpipeline.DummyProcess4_1")

# inputs
self.add_field("input1", str, optional=False)
Expand Down
18 changes: 9 additions & 9 deletions capsul/process/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def json(self, include_parameters=True):
return result

def json_parameters(self):
return super(Process, self).json()
return super().json()

def before_execute(self, context):
"""This method is called by CapsulEngine before calling
Expand Down Expand Up @@ -543,7 +543,7 @@ def __init__(

def before_execute(self, context):
"""Method to copy files before executing the process."""
# super(FileCopyProcess, self).before_execute(context)
# super().before_execute(context)

if self.destination is None:
output_directory = getattr(self, "output_directory", None)
Expand Down Expand Up @@ -583,7 +583,7 @@ def after_execute(self, exec_result, context):
"""Method to clean-up temporary workspace after process
execution.
"""
# exec_result = super(FileCopyProcess, self).after_execute(
# exec_result = super().after_execute(
# exec_result, context)
if self.use_temp_output_dir:
self._move_outputs()
Expand Down Expand Up @@ -914,7 +914,7 @@ def init_with_skip(self, *args, **kwargs):
if len(stack) >= 2:
s2 = stack[-2]
if s2[2] == "nipype_factory":
instance = super(NipypeProcess, cls).__new__(cls, *args, **kwargs)
instance = super().__new__(cls, *args, **kwargs)
setattr(instance, "__%s_np_init_done__" % cls.__name__, False)
return instance
nipype_class = getattr(cls, "_nipype_class_type", None)
Expand Down Expand Up @@ -947,7 +947,7 @@ def init_with_skip(self, *args, **kwargs):
instance.id = instance.__class__.__module__ + "." + instance.name
instance.__postinit__(*nargs, **nkwargs)
else:
instance = super(NipypeProcess, cls).__new__(cls, *args, **kwargs)
instance = super().__new__(cls, *args, **kwargs)
setattr(instance, "__%s_np_init_done__" % cls.__name__, False)
return instance

Expand Down Expand Up @@ -1037,7 +1037,7 @@ class Smooth(NipypeProcess):
return

self.__NipypeProcess_np_init_done__ = True
# super(NipypeProcess, self).__init__(*args, **kwargs)
# super().__init__(*args, **kwargs)

# Set some class attributes that characterize the nipype interface
if nipype_instance is None:
Expand Down Expand Up @@ -1076,7 +1076,7 @@ class Smooth(NipypeProcess):
]
if use_temp_output_dir is None:
use_temp_output_dir = True
super(NipypeProcess, self).__init__(
super().__init__(
definition=definition,
activate_copy=True,
inputs_to_copy=inputs_to_copy,
Expand All @@ -1089,7 +1089,7 @@ class Smooth(NipypeProcess):
else:
if use_temp_output_dir is None:
use_temp_output_dir = False
super(NipypeProcess, self).__init__(
super().__init__(
definition=definition,
activate_copy=False,
use_temp_output_dir=use_temp_output_dir,
Expand Down Expand Up @@ -1220,4 +1220,4 @@ def after_execute(self, exec_result, context):
)
if os.path.exists(script_file):
shutil.move(script_file, getattr(self, script_tname))
return super(NipypeProcess, self).after_execute(exec_result, context)
return super().after_execute(exec_result, context)
2 changes: 1 addition & 1 deletion capsul/process/test/test_metadata_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DummyProcess(Process):
f: float = field(output=False)

def __init__(self, definition):
super(DummyProcess, self).__init__(definition)
super().__init__(definition)
self.add_field("truc", type_=File, write=False)
self.add_field("bidule", type_=File, write=True)

Expand Down
2 changes: 1 addition & 1 deletion capsul/qt_apps/pipeline_viewer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PipelineViewerApp(Application):
def __init__(self, *args, **kwargs):
"""Method to initialize the PipelineViewerApp class."""
# Inhetritance
super(PipelineViewerApp, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

# Initialize the application
self.window = None
Expand Down
2 changes: 1 addition & 1 deletion capsul/qt_gui/widgets/activation_inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, pipeline_path, record_file=None, *args, **kwargs):
a file where the pipeline activation steps are stored.
"""
# Inhetritance
super(ActivationInspectorApp, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

# Load the pipeline
self.pipeline = executable(pipeline_path)
Expand Down
2 changes: 1 addition & 1 deletion capsul/qt_gui/widgets/attributed_process_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
user_level, and will only be visible if the ControllerWidget
userl_evel is more than (or equal) the field level.
"""
super(AttributedProcessWidget, self).__init__()
super().__init__()
self.setLayout(QtGui.QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
if exec_meta is None:
Expand Down
2 changes: 1 addition & 1 deletion capsul/qt_gui/widgets/links_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CapsulLinkDebuggerView(QtGui.QWidget):
VALUE = 4

def __init__(self, pipeline, ui_file=None, record_file=None, parent=None):
super(CapsulLinkDebuggerView, self).__init__(parent)
super().__init__(parent)

# load the user interface window
if ui_file is None:
Expand Down
Loading

0 comments on commit b8f571a

Please sign in to comment.