From 8733167ae3eb983e1724ee2d4f2049498e12eaed Mon Sep 17 00:00:00 2001 From: furtest Date: Tue, 5 May 2026 12:05:18 +0200 Subject: [PATCH] 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. --- src/unisync/synchroniser.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/unisync/synchroniser.py b/src/unisync/synchroniser.py index ae51731..138d356 100644 --- a/src/unisync/synchroniser.py +++ b/src/unisync/synchroniser.py @@ -190,8 +190,8 @@ class Synchroniser: ) def sync(self, remote_root:str, local_root:str, - paths:list=[], ignore:list=[], force:bool=False, - other:list=[] + paths:list | None=None, ignore:list | None = None, force:bool=False, + other:list | None = None ) -> None: """Performs the synchronisation by calling unison. @@ -217,6 +217,13 @@ class Synchroniser: was interrupted. 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 ] for arg in self.args_bool: command.append(f"-{arg}")