synchroniser : misc pylint suggested fixes

- Do not use mutables as default arguments
- Remove trailing whitespaces
- Initialise using [] and {} instead of list() and dict()
- Use is not None instead of != None
- Some other small stuff
This commit is contained in:
2026-05-05 12:25:52 +02:00
parent 22d30b4df7
commit 7cb96fcd45
+16 -14
View File
@@ -10,7 +10,6 @@ the remote.
import subprocess
import os
import sys
import time
import logging
from pathlib import Path
@@ -50,26 +49,27 @@ class Synchroniser:
"""
def __init__(self, remote:str, local:str, user:str, ip:str, port:int=22,
args_bool:list=[], args_value:dict={}, ssh_settings:dict={},
backup:BackupConfig | None = None
args_bool:list[str] | None = None, args_value:dict[str, str] | None = None,
ssh_settings:dict[str, str] | None = None, backup:BackupConfig | None = None
):
"""Initialises an instance of Synchroniser.
"""
self.remote_dir:str = remote
self.local:str = local
self.args_bool:list[str] = args_bool
self.args_value:dict[str, str] = args_value
self.ssh_settings:dict[str, str] = dict()
self.args_bool:list[str] = args_bool if args_bool is not None else []
self.args_value:dict[str, str] = args_value if args_value is not None else {}
self.ssh_settings:dict[str, str] = ssh_settings if ssh_settings is not None else {}
self.remote_user:str = user
self.remote_ip:str = ip
self.remote_ip:str = ip
self.remote_port:int = port
self.files_extra:list = list()
self.links_extra:list = list()
self.files_extra:list = []
self.links_extra:list = []
self.control_path:str = ""
if(backup != None and backup.enabled):
if backup is not None and backup.enabled:
backup = cast(BackupConfig, backup)
self.files_extra.append("-backup")
if(backup.selection != ""):
if backup.selection != "":
self.files_extra.append(backup.selection)
else:
self.files_extra.append("Name *")
@@ -91,8 +91,10 @@ class Synchroniser:
"-ignore",
f"Name {backup.backupprefix[:-1]}"
])
def create_ssh_master_connection(self, control_path:str="~/.ssh/control_%C", connection_timeout:int=60) -> None:
def create_ssh_master_connection(self, control_path:str="~/.ssh/control_%C",
connection_timeout:int=60
) -> None:
"""Creates an ssh master connection.
It is used so the user only has to authenticate once to the remote server.
@@ -322,5 +324,5 @@ class Synchroniser:
f"{self.remote_user}@{self.remote_ip}:{self.remote_dir}/.data",
str(path_to_mount)
]
completed_process = subprocess.run(command)
completed_process = subprocess.run(command, check=True)
completed_process.check_returncode()