synchroniser : do not use mutable as default argument
Default arguments are evaluated only once meaning if they are mutables they are shared between every function invocation. See the warning here: https://docs.python.org/3/tutorial/controlflow.html#default-argument-values So use None instead of [] and replace it by the list in the body of the function.
This commit is contained in:
@@ -190,8 +190,8 @@ class Synchroniser:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def sync(self, remote_root:str, local_root:str,
|
def sync(self, remote_root:str, local_root:str,
|
||||||
paths:list=[], ignore:list=[], force:bool=False,
|
paths:list | None=None, ignore:list | None = None, force:bool=False,
|
||||||
other:list=[]
|
other:list | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Performs the synchronisation by calling unison.
|
"""Performs the synchronisation by calling unison.
|
||||||
|
|
||||||
@@ -217,6 +217,13 @@ class Synchroniser:
|
|||||||
was interrupted.
|
was interrupted.
|
||||||
If this happens propagate the error to unisync.
|
If this happens propagate the error to unisync.
|
||||||
"""
|
"""
|
||||||
|
if paths is None:
|
||||||
|
paths = []
|
||||||
|
if ignore is None:
|
||||||
|
ignore = []
|
||||||
|
if other is None:
|
||||||
|
other = []
|
||||||
|
|
||||||
command = [ "/usr/bin/unison", "-root", remote_root, "-root", local_root ]
|
command = [ "/usr/bin/unison", "-root", remote_root, "-root", local_root ]
|
||||||
for arg in self.args_bool:
|
for arg in self.args_bool:
|
||||||
command.append(f"-{arg}")
|
command.append(f"-{arg}")
|
||||||
|
|||||||
Reference in New Issue
Block a user