Skip to content

Commit

Permalink
Remove lists as default arguments in functions
Browse files Browse the repository at this point in the history
Signed-off-by: Evangelos Lamprou <e.lamprou@upnet.gr>
  • Loading branch information
vagos committed Oct 31, 2023
1 parent d18f7bc commit 27b13fa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
6 changes: 5 additions & 1 deletion compiler/definitions/ir/nodes/dfs_split_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

class DFSSplitReader(DFGNode):
def __init__(self, inputs, outputs, com_name, com_category,
com_options = [], com_redirs = [], com_assignments=[]):
com_options = None, com_redirs = None, com_assignments=None):

com_options = [] if com_options is None else com_options
com_redirs = [] if com_redirs is None else com_redirs
com_assignments = [] if com_assignments is None else com_assignments

super().__init__(inputs, outputs, com_name, com_category,
com_options=com_options,
com_redirs=com_redirs,
Expand Down
6 changes: 5 additions & 1 deletion compiler/definitions/ir/nodes/hdfs_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

class HDFSCat(DFGNode):
def __init__(self, inputs, outputs, com_name, com_category,
com_options = [], com_redirs = [], com_assignments=[]):
com_options = None, com_redirs = None, com_assignments=None):
com_options = [] if com_options is None else com_options
com_redirs = [] if com_redirs is None else com_redirs
com_assignments = [] if com_assignments is None else com_assignments

assert(str(com_name) == "hdfs")
assert(str(com_options[0][1]) == "dfs" and str(com_options[1][1]) == "-cat")
super().__init__(inputs, outputs, com_name, com_category,
Expand Down
5 changes: 4 additions & 1 deletion compiler/definitions/ir/nodes/remote_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

class RemotePipe(DFGNode):
def __init__(self, inputs, outputs, com_name, com_category,
com_options = [], com_redirs = [], com_assignments=[]):
com_options = None, com_redirs = None, com_assignments=None):
com_options = [] if com_options is None else com_options
com_redirs = [] if com_redirs is None else com_redirs
com_assignments = [] if com_assignments is None else com_assignments
super().__init__(inputs, outputs, com_name, com_category,
com_options=com_options,
com_redirs=com_redirs,
Expand Down
4 changes: 2 additions & 2 deletions compiler/dspash/worker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def host(self):
return self._host

class WorkersManager():
def __init__(self, workers: WorkerConnection = []):
self.workers = workers
def __init__(self, workers: WorkerConnection = None):
self.workers = [] if workers is None else workers
self.host = socket.gethostbyname(socket.gethostname())
self.args = copy.copy(config.pash_args)
# Required to create a correct multi sink graph
Expand Down
4 changes: 3 additions & 1 deletion compiler/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def add_var_for_descriptor(operand):


def compile_command_to_DFG(fileIdGen, command, options,
redirections=[]):
redirections=None):
redirections = [] if redirections is None else redirections

command_invocation: CommandInvocationInitial = parse_arg_list_to_command_invocation(command, options)
io_info: InputOutputInfo = get_input_output_info_from_cmd_invocation_util(command_invocation)
if io_info is None:
Expand Down
12 changes: 8 additions & 4 deletions compiler/shell_ast/ast_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def redir_stdout_to_file(arg):
def redir_file_to_stdin(arg):
return make_kv("File",["From", 0, arg])

def make_background(body, redirections=[]):
def make_background(body, redirections=None):
redirections = [] if redirections is None else redirections
lineno = 0
node = make_kv("Background", [lineno, body, redirections])
return node
Expand All @@ -106,12 +107,15 @@ def make_backquote(node):
node = make_kv("B", node)
return node

def make_subshell(body, redirections=[]):
def make_subshell(body, redirections=None):
redirections = [] if redirections is None else redirections
lineno = 0
node = make_kv("Subshell", [lineno, body, redirections])
return node

def make_command(arguments, redirections=[], assignments=[]):
def make_command(arguments, redirections=None, assignments=None):
assignments = [] if assignments is None else assignments
redirections = [] if redirections is None else redirections
lineno = 0
node = make_kv("Command", [lineno, assignments, arguments, redirections])
return node
Expand Down Expand Up @@ -224,4 +228,4 @@ def make_echo_ast(argument, var_file_path):
line_number = 0
node = make_kv('Command', [line_number, [], arguments, []])
nodes.append(node)
return nodes
return nodes

0 comments on commit 27b13fa

Please sign in to comment.