From a40978ae1b00b1dd16685f7a4e83e2bb81e373a5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Tue, 27 Aug 2024 02:46:13 +0200 Subject: [PATCH] blacken the code --- src/borg/archiver/__init__.py | 15 +++++++-------- src/borg/archiver/compact_cmd.py | 14 ++++++-------- src/borg/helpers/__init__.py | 1 + src/borg/helpers/process.py | 8 +++++--- src/borg/testsuite/archiver/disk_full.py | 1 + src/borg/testsuite/archiver/mount_cmds.py | 10 ++++++---- 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/borg/archiver/__init__.py b/src/borg/archiver/__init__.py index e1c8512ab..2279b90dd 100644 --- a/src/borg/archiver/__init__.py +++ b/src/borg/archiver/__init__.py @@ -582,14 +582,13 @@ def main(): # pragma: no cover # Register fault handler for SIGSEGV, SIGFPE, SIGABRT, SIGBUS and SIGILL. faulthandler.enable() - with signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), signal_handler( - "SIGHUP", raising_signal_handler(SigHup) - ), signal_handler("SIGTERM", raising_signal_handler(SigTerm)), signal_handler( - "SIGUSR1", sig_info_handler - ), signal_handler( - "SIGUSR2", sig_trace_handler - ), signal_handler( - "SIGINFO", sig_info_handler + with ( + signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), + signal_handler("SIGHUP", raising_signal_handler(SigHup)), + signal_handler("SIGTERM", raising_signal_handler(SigTerm)), + signal_handler("SIGUSR1", sig_info_handler), + signal_handler("SIGUSR2", sig_trace_handler), + signal_handler("SIGINFO", sig_info_handler), ): archiver = Archiver() msg = msgid = tb = None diff --git a/src/borg/archiver/compact_cmd.py b/src/borg/archiver/compact_cmd.py index e0d37e3ac..51144a107 100644 --- a/src/borg/archiver/compact_cmd.py +++ b/src/borg/archiver/compact_cmd.py @@ -39,13 +39,9 @@ def garbage_collect(self): logger.info("Getting object IDs present in the repository...") self.repository_chunks = self.get_repository_chunks() logger.info("Computing object IDs used by archives...") - ( - self.used_chunks, - self.wanted_chunks, - self.total_files, - self.total_size, - self.archives_count, - ) = self.analyze_archives() + (self.used_chunks, self.wanted_chunks, self.total_files, self.total_size, self.archives_count) = ( + self.analyze_archives() + ) self.report_and_delete() logger.info("Finished compaction / garbage collection...") @@ -134,7 +130,9 @@ def report_and_delete(self): count = len(self.repository_chunks) logger.info(f"Overall statistics, considering all {self.archives_count} archives in this repository:") - logger.info(f"Source data size was {format_file_size(self.total_size, precision=0)} in {self.total_files} files.") + logger.info( + f"Source data size was {format_file_size(self.total_size, precision=0)} in {self.total_files} files." + ) dsize = sum(self.used_chunks[id] for id in self.repository_chunks) logger.info(f"Repository size is {format_file_size(self.repository_size, precision=0)} in {count} objects.") if self.total_size != 0: diff --git a/src/borg/helpers/__init__.py b/src/borg/helpers/__init__.py index 53555e7e6..d62e45f1d 100644 --- a/src/borg/helpers/__init__.py +++ b/src/borg/helpers/__init__.py @@ -5,6 +5,7 @@ Code used to be in borg/helpers.py but was split into the modules in this package, which are imported into here for compatibility. """ + import os from typing import List from collections import namedtuple diff --git a/src/borg/helpers/process.py b/src/borg/helpers/process.py index 4149b7eda..cd8303d85 100644 --- a/src/borg/helpers/process.py +++ b/src/borg/helpers/process.py @@ -82,9 +82,11 @@ def daemonizing(*, timeout=5): logger.debug("Daemonizing: Foreground process (%s, %s, %s) is waiting for background process..." % old_id) exit_code = EXIT_SUCCESS # Indeed, SIGHUP and SIGTERM handlers should have been set on archiver.run(). Just in case... - with signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), signal_handler( - "SIGHUP", raising_signal_handler(SigHup) - ), signal_handler("SIGTERM", raising_signal_handler(SigTerm)): + with ( + signal_handler("SIGINT", raising_signal_handler(KeyboardInterrupt)), + signal_handler("SIGHUP", raising_signal_handler(SigHup)), + signal_handler("SIGTERM", raising_signal_handler(SigTerm)), + ): try: if timeout > 0: time.sleep(timeout) diff --git a/src/borg/testsuite/archiver/disk_full.py b/src/borg/testsuite/archiver/disk_full.py index 5f85a2931..0d3617381 100644 --- a/src/borg/testsuite/archiver/disk_full.py +++ b/src/borg/testsuite/archiver/disk_full.py @@ -14,6 +14,7 @@ if the directory does not exist, the test will be skipped. """ + import errno import os import random diff --git a/src/borg/testsuite/archiver/mount_cmds.py b/src/borg/testsuite/archiver/mount_cmds.py index 292aff748..1a8bb12ff 100644 --- a/src/borg/testsuite/archiver/mount_cmds.py +++ b/src/borg/testsuite/archiver/mount_cmds.py @@ -32,16 +32,18 @@ def test_fuse_mount_hardlinks(archivers, request): ignore_perms = ["-o", "ignore_permissions,defer_permissions"] else: ignore_perms = ["-o", "ignore_permissions"] - with fuse_mount(archiver, mountpoint, "-a", "test", "--strip-components=2", *ignore_perms), changedir( - os.path.join(mountpoint, "test") + with ( + fuse_mount(archiver, mountpoint, "-a", "test", "--strip-components=2", *ignore_perms), + changedir(os.path.join(mountpoint, "test")), ): assert os.stat("hardlink").st_nlink == 2 assert os.stat("subdir/hardlink").st_nlink == 2 assert open("subdir/hardlink", "rb").read() == b"123456" assert os.stat("aaaa").st_nlink == 2 assert os.stat("source2").st_nlink == 2 - with fuse_mount(archiver, mountpoint, "input/dir1", "-a", "test", *ignore_perms), changedir( - os.path.join(mountpoint, "test") + with ( + fuse_mount(archiver, mountpoint, "input/dir1", "-a", "test", *ignore_perms), + changedir(os.path.join(mountpoint, "test")), ): assert os.stat("input/dir1/hardlink").st_nlink == 2 assert os.stat("input/dir1/subdir/hardlink").st_nlink == 2