diff --git a/pyproject.toml b/pyproject.toml index f3933d6..821202a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,4 +26,6 @@ docs = [ "sphinx (>=9.1.0,<10.0.0)", "sphinx-rtd-theme (>=3.0.2,<4.0.0)", ] - +dev = [ + "pylint (>=4.0.4,<5.0.0)" +] diff --git a/src/unisync/config.py b/src/unisync/config.py index d504df1..6b21078 100644 --- a/src/unisync/config.py +++ b/src/unisync/config.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later from configparser import UNNAMED_SECTION -from dataclasses import dataclass, field +from dataclasses import dataclass from pathlib import Path import ipaddress import configparser @@ -30,8 +30,8 @@ class ServerConfig: if self.ip != "": try: ipaddress.ip_address(self.ip) - except ValueError: - raise ValueError("The provided ip address is invalid") + except ValueError as e: + raise ValueError("The provided ip address is invalid") from e @dataclass class RootsConfig: @@ -120,13 +120,13 @@ def load_config(config_path:str) -> Config: Path(config.get(other_section, "cache_dir_path", fallback=DEFAULT_MISC_CACHE_DIR_PATH)).expanduser() ) - args_bool = list() - args_val = dict() + args_bool = [] + args_val = {} if "Unison" in config.sections(): for key, val in config.items("Unison"): if key in config["DEFAULT"].keys(): continue - elif val == "" or val == None: + if val in ("", None): args_bool.append(key) else: args_val[key] = val diff --git a/src/unisync/defaults.py b/src/unisync/defaults.py index 55f0062..cd12b49 100644 --- a/src/unisync/defaults.py +++ b/src/unisync/defaults.py @@ -6,7 +6,7 @@ from pathlib import Path # Commented out values are part of the config but are required so there is no defaults. # This allows this file to be a list of all the config options. -# DEFAULT_SERVER_USER: str = "" +# DEFAULT_SERVER_USER: str = "" DEFAULT_SERVER_SSHARGS: str = "" DEFAULT_SERVER_HOSTNAME: str = "" DEFAULT_SERVER_IP: str = "" diff --git a/src/unisync/main.py b/src/unisync/main.py index dd70ca5..af34141 100644 --- a/src/unisync/main.py +++ b/src/unisync/main.py @@ -7,7 +7,7 @@ from unisync.argparser import create_argparser from unisync.runners import unisync_sync, unisync_add, unisync_mount from unisync.config import load_config from unisync.synchroniser import Synchroniser -from unisync.paths import * +from unisync.paths import PathsManager def main(): parser = create_argparser(unisync_sync, unisync_add, unisync_mount) @@ -15,14 +15,13 @@ def main(): config_path: Path = Path("~/.config/unisync/config.ini").expanduser() # Check if --config is set - if cli_args.config != None and Path(cli_args.config).is_file(): + if cli_args.config is not None and Path(cli_args.config).is_file(): config = load_config(cli_args.config) elif config_path.is_file(): config = load_config(str(config_path)) else: # TODO replace the next line with something to do if no config file is found config = load_config(str(config_path)) - pass # TODO: make the command line arguments work and override the config options diff --git a/src/unisync/paths.py b/src/unisync/paths.py index a13bc50..127560e 100644 --- a/src/unisync/paths.py +++ b/src/unisync/paths.py @@ -92,7 +92,7 @@ class PathsManager: Writes a list of new paths to the file """ current_paths = self.get_paths_to_sync() - paths_to_add = list() + paths_to_add = [] # Check if one of the parent is already being synchronised # If so there is no need to add the child path for new_path in paths: diff --git a/src/unisync/runners.py b/src/unisync/runners.py index 09d5a9a..0e65dc9 100644 --- a/src/unisync/runners.py +++ b/src/unisync/runners.py @@ -6,6 +6,7 @@ from unisync.paths import PathsManager from unisync.config import Config def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config: Config): + del config # The function signature must be the same for all runners if synchroniser.create_ssh_master_connection() != 0: print("Connection failed quitting") return 1 @@ -13,8 +14,8 @@ def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config: synchroniser.sync_files(paths_manager.get_paths_to_sync()) synchroniser.sync_links(paths_manager.get_paths_to_sync()) - - # TODO: check the config options and do or don't do the following + + # TODO check the config options and do or don't do the following synchroniser.update_links() #synchroniser.mount_remote_dir()