From 8d2fd2a30ee5a60c6f5561a60033385bce8f0964 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 25 Dec 2023 02:34:44 +0100 Subject: [PATCH] ran pyupgrade --py39-plus ./**/*.py --- src/borg/archiver.py | 6 +++--- src/borg/crypto/key.py | 4 ++-- src/borg/testsuite/chunker_pytest.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 48353cd35..b14bccf42 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -1449,7 +1449,7 @@ class Archiver: def _info_archives(self, args, repository, manifest, key, cache): def format_cmdline(cmdline): - return remove_surrogates(' '.join(shlex.quote(x) for x in cmdline)) + return remove_surrogates(shlex.join(cmdline)) if args.location.archive: archive_names = (args.location.archive,) @@ -2212,7 +2212,7 @@ class Archiver: if len(id) != 32: # 256bit raise ValueError("id must be 256bits or 64 hex digits") except ValueError as err: - print("object id %s is invalid [%s]." % (hex_id, str(err))) + print("object id {} is invalid [{}].".format(hex_id, str(err))) return EXIT_ERROR try: data = repository.get(id) @@ -2244,7 +2244,7 @@ class Archiver: if len(id) != 32: # 256bit raise ValueError("id must be 256bits or 64 hex digits") except ValueError as err: - print("object id %s is invalid [%s]." % (hex_id, str(err))) + print("object id {} is invalid [{}].".format(hex_id, str(err))) return EXIT_ERROR repository.put(id, data) print("object %s put." % hex_id) diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py index 57c528aef..6a79b7499 100644 --- a/src/borg/crypto/key.py +++ b/src/borg/crypto/key.py @@ -512,7 +512,7 @@ class Passphrase(str): # passcommand is a system command (not inside pyinstaller env) env = prepare_subprocess_env(system=True) try: - passphrase = subprocess.check_output(shlex.split(passcommand), universal_newlines=True, env=env) + passphrase = subprocess.check_output(shlex.split(passcommand), text=True, env=env) except (subprocess.CalledProcessError, FileNotFoundError) as e: raise PasscommandFailure(e) return cls(passphrase.rstrip('\n')) @@ -785,7 +785,7 @@ class KeyfileKey(ID_HMAC_SHA_256, KeyfileKeyBase): raise KeyfileMismatchError(self.repository._location.canonical_path(), filename) # we get here if it really looks like a borg key for this repo, # do some more checks that are close to how borg reads/parses the key. - with open(filename, 'r') as fd: + with open(filename) as fd: lines = fd.readlines() if len(lines) < 2: logger.warning(f"borg key sanity check: expected 2+ lines total. [{filename}]") diff --git a/src/borg/testsuite/chunker_pytest.py b/src/borg/testsuite/chunker_pytest.py index 7ac319245..aa2d9cddc 100644 --- a/src/borg/testsuite/chunker_pytest.py +++ b/src/borg/testsuite/chunker_pytest.py @@ -149,8 +149,8 @@ def test_buzhash_chunksize_distribution(): chunks_count = len(chunks) min_chunksize_observed = min(chunk_sizes) max_chunksize_observed = max(chunk_sizes) - min_count = sum((int(size == 2 ** min_exp) for size in chunk_sizes)) - max_count = sum((int(size == 2 ** max_exp) for size in chunk_sizes)) + min_count = sum(int(size == 2 ** min_exp) for size in chunk_sizes) + max_count = sum(int(size == 2 ** max_exp) for size in chunk_sizes) print(f"count: {chunks_count} min: {min_chunksize_observed} max: {max_chunksize_observed} " f"min count: {min_count} max count: {max_count}") # usually there will about 64 chunks