From 435b05a3167d1723973005689f88921eef8309df Mon Sep 17 00:00:00 2001 From: VaibhavNexus Date: Wed, 18 Mar 2026 16:24:26 +0530 Subject: [PATCH 1/4] Add type annotations to normalize_path and pattern function --- src/vorta/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vorta/utils.py b/src/vorta/utils.py index 3b6229897..03639a281 100644 --- a/src/vorta/utils.py +++ b/src/vorta/utils.py @@ -52,7 +52,7 @@ def run(self): self.signal.emit(self.path, str(self.size), str(self.files_count)) -def normalize_path(path): +def normalize_path(path: str) -> str: """normalize paths for MacOS (but do nothing on other platforms)""" # HFS+ converts paths to a canonical form, so users shouldn't be required to enter an exact match. # Windows and Unix filesystems allow different forms, so users always have to enter an exact match. @@ -62,7 +62,7 @@ def normalize_path(path): # prepare patterns as borg does # see `FnmatchPattern._prepare` at # https://github.com/borgbackup/borg/blob/master//src/borg/patterns.py -def prepare_pattern(pattern): +def prepare_pattern(pattern: str) -> str: """Prepare and process fnmatch patterns as borg does""" if pattern.endswith(os.path.sep): # trailing sep indicates that the contents should be excluded From cfc6d517e247674316e406dd710d179507096561 Mon Sep 17 00:00:00 2001 From: VaibhavNexus Date: Thu, 19 Mar 2026 20:56:29 +0530 Subject: [PATCH 2/4] Add return type annotations to config functions --- src/vorta/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vorta/config.py b/src/vorta/config.py index 2bf14add6..65f38f57f 100644 --- a/src/vorta/config.py +++ b/src/vorta/config.py @@ -17,7 +17,7 @@ def default_dev_dir() -> Path: return Path(__file__).parent.parent.parent / '.dev_config' -def init_from_platformdirs(): +def init_from_platformdirs() -> None: """Initializes config dirs for system-wide use""" dirs = platformdirs.PlatformDirs(APP_NAME, APP_AUTHOR) init(dirs.user_data_path, dirs.user_log_path, dirs.user_cache_path, dirs.user_cache_path / 'tmp', Path.home()) @@ -35,7 +35,7 @@ def init_dev_mode(dir: Path): ) -def init(settings: Path, logs: Path, cache: Path, tmp: Path, bootstrap: Path): +def init(settings: Path, logs: Path, cache: Path, tmp: Path, bootstrap: Path) -> None: """Initializes config directories with provided paths""" global SETTINGS_DIR global LOG_DIR From bb606512c61e6b661fb1718965bfcf9989a54dd3 Mon Sep 17 00:00:00 2001 From: VaibhavNexus Date: Thu, 19 Mar 2026 21:02:50 +0530 Subject: [PATCH 3/4] Add type annotation to init_logger --- src/vorta/log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vorta/log.py b/src/vorta/log.py index 0c87e72db..60f65db9d 100644 --- a/src/vorta/log.py +++ b/src/vorta/log.py @@ -14,7 +14,7 @@ logger = logging.getLogger() -def init_logger(background=False): +def init_logger(background: bool = False) -> None: logger.setLevel(logging.DEBUG) logging.getLogger('peewee').setLevel(logging.INFO) logging.getLogger('PyQt6').setLevel(logging.INFO) From d8240f4da2b41ae97cd0fe16b710f292d42d55d5 Mon Sep 17 00:00:00 2001 From: VaibhavNexus Date: Thu, 19 Mar 2026 21:17:32 +0530 Subject: [PATCH 4/4] Add type annotation for namer callable in log.py --- src/vorta/log.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/vorta/log.py b/src/vorta/log.py index 60f65db9d..0f5018f17 100644 --- a/src/vorta/log.py +++ b/src/vorta/log.py @@ -3,11 +3,11 @@ - linux: $HOME/.cache/Vorta/log - macOS: $HOME/Library/Logs/Vorta - """ import logging from logging.handlers import TimedRotatingFileHandler +from typing import Callable from vorta import config @@ -20,20 +20,31 @@ def init_logger(background: bool = False) -> None: logging.getLogger('PyQt6').setLevel(logging.INFO) # create logging format - formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + formatter = logging.Formatter( + '%(asctime)s - %(name)s - %(levelname)s - %(message)s' + ) + + # create file handler + fh = TimedRotatingFileHandler( + config.LOG_DIR / 'vorta.log', + when='d', + interval=1, + backupCount=5 + ) - # create handlers - fh = TimedRotatingFileHandler(config.LOG_DIR / 'vorta.log', when='d', interval=1, backupCount=5) # ensure ".log" suffix - fh.namer = lambda log_name: log_name.replace(".log", "") + ".log" + namer: Callable[[str], str] = ( + lambda log_name: log_name.replace(".log", "") + ".log" + ) + fh.namer = namer + fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) - if background: - pass - else: # log to console, when running in foreground + if not background: + # log to console when running in foreground ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) ch.setFormatter(formatter) - logger.addHandler(ch) + logger.addHandler(ch) \ No newline at end of file