From 5013121bd85c24ab6ee67dd2bc157e2d3facc770 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 26 Jul 2023 01:10:24 +0200 Subject: [PATCH] fix E501 --- setup.cfg | 14 +++----------- src/borg/archive.py | 4 ++-- src/borg/archiver/_common.py | 3 ++- src/borg/archiver/rlist_cmd.py | 2 +- src/borg/cache.py | 5 +++-- src/borg/helpers/parseformat.py | 2 +- src/borg/helpers/shellpattern.py | 7 +++---- src/borg/manifest.py | 3 ++- src/borg/remote.py | 2 +- src/borg/repository.py | 14 ++++++++------ src/borg/testsuite/crypto.py | 6 ++++-- src/borg/testsuite/helpers.py | 6 ++++-- src/borg/testsuite/locking.py | 18 +++++++++--------- src/borg/testsuite/platform.py | 8 ++++++-- 14 files changed, 49 insertions(+), 45 deletions(-) diff --git a/setup.cfg b/setup.cfg index 1e1415f6..e45e3347 100644 --- a/setup.cfg +++ b/setup.cfg @@ -96,30 +96,22 @@ ignore = W503, E203, F405 per_file_ignores = src/borg/archive.py:E402,E501 src/borg/archiver/__init__.py:E402 - src/borg/archiver/_common.py:E501 src/borg/archiver/help_cmd.py:E501 - src/borg/archiver/rlist_cmd.py:E501 src/borg/cache.py:E402,E501 src/borg/fuse.py:E402 - src/borg/manifest.py:E402,E501 - src/borg/remote.py:E501 - src/borg/repository.py:E501 + src/borg/manifest.py:E402 src/borg/xattr.py:E402 src/borg/crypto/key.py:E402 src/borg/helpers/__init__.py:F401 src/borg/helpers/misc.py:E402 - src/borg/helpers/parseformat.py:E402,E501 + src/borg/helpers/parseformat.py:E402 src/borg/helpers/process.py:E402 - src/borg/helpers/shellpattern.py:E501 src/borg/platform/__init__.py:F401 src/borg/platform/base.py:E402 src/borg/testsuite/archiver/disk_full.py:F811 src/borg/testsuite/archiver/return_codes.py:F811 src/borg/testsuite/benchmark.py:F811 - src/borg/testsuite/crypto.py:E501 - src/borg/testsuite/helpers.py:E501 - src/borg/testsuite/locking.py:E501 - src/borg/testsuite/platform.py:E501,F811 + src/borg/testsuite/platform.py:F811 max_line_length = 120 exclude = build,dist,.git,.idea,.cache,.tox diff --git a/src/borg/archive.py b/src/borg/archive.py index 60c647da..808f901f 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -974,8 +974,8 @@ Duration: {0.duration} if not self.noacls: acl_set(path, item, self.numeric_ids, fd=fd) if not self.noxattrs and "xattrs" in item: - # chown removes Linux capabilities, so set the extended attributes at the end, after chown, since they include - # the Linux capabilities in the "security.capability" attribute. + # chown removes Linux capabilities, so set the extended attributes at the end, after chown, + # since they include the Linux capabilities in the "security.capability" attribute. warning = xattr.set_all(fd or path, item.xattrs, follow_symlinks=False) if warning: set_ec(EXIT_WARNING) diff --git a/src/borg/archiver/_common.py b/src/borg/archiver/_common.py index f1d33ec8..6d0d06e8 100644 --- a/src/borg/archiver/_common.py +++ b/src/borg/archiver/_common.py @@ -85,7 +85,8 @@ def with_repository( :param manifest: load manifest and repo_objs (key), pass them as keyword arguments :param cache: open cache, pass it as keyword argument (implies manifest) :param secure: do assert_secure after loading manifest - :param compatibility: mandatory if not create and (manifest or cache), specifies mandatory feature categories to check + :param compatibility: mandatory if not create and (manifest or cache), specifies mandatory + feature categories to check """ # Note: with_repository decorator does not have a "key" argument (yet?) compatibility = compat_check( diff --git a/src/borg/archiver/rlist_cmd.py b/src/borg/archiver/rlist_cmd.py index e026a336..1e1f7b4e 100644 --- a/src/borg/archiver/rlist_cmd.py +++ b/src/borg/archiver/rlist_cmd.py @@ -66,7 +66,7 @@ class RListMixIn: # Strings are left-aligned, numbers are right-aligned. # Note: time columns except ``isomtime``, ``isoctime`` and ``isoatime`` cannot be padded. $ borg rlist --format '{archive:36} {time} [{id}]{NL}' /path/to/repo - ArchiveFoo Thu, 2021-12-09 10:22:28 [0b8e9a312bef3f2f6e2d0fc110c196827786c15eba0188738e81697a7fa3b274] + ArchiveFoo Thu, 2021-12-09 10:22:28 [0b8e9...3b274] ... The following keys are always available: diff --git a/src/borg/cache.py b/src/borg/cache.py index 015ee7fc..77df3fc5 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -895,8 +895,9 @@ class LocalCache(CacheStatsMixin): self.begin_txn() with cache_if_remote(self.repository, decrypted_cache=self.repo_objs) as decrypted_repository: - # TEMPORARY HACK: to avoid archive index caching, create a FILE named ~/.cache/borg/REPOID/chunks.archive.d - - # this is only recommended if you have a fast, low latency connection to your repo (e.g. if repo is local disk) + # TEMPORARY HACK: + # to avoid archive index caching, create a FILE named ~/.cache/borg/REPOID/chunks.archive.d - + # this is only recommended if you have a fast, low latency connection to your repo (e.g. if repo is local). self.do_cache = os.path.isdir(archive_path) self.chunks = create_master_idx(self.chunks) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index 79928a61..7297db37 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -456,7 +456,7 @@ class Location: (?:file://)? # optional file protocol (?P (?:[a-zA-Z]:)? # Drive letter followed by a colon (optional) - (?:[^:]+) # Anything which does not contain a :, at least one character + (?:[^:]+) # Anything which does not contain a :, at least one char ) """, re.VERBOSE, diff --git a/src/borg/helpers/shellpattern.py b/src/borg/helpers/shellpattern.py index 7dc3ee09..12b0bba2 100644 --- a/src/borg/helpers/shellpattern.py +++ b/src/borg/helpers/shellpattern.py @@ -6,10 +6,9 @@ from queue import LifoQueue def translate(pat, match_end=r"\Z"): """Translate a shell-style pattern to a regular expression. - The pattern may include ``**`` ( stands for the platform-specific path separator; "/" on POSIX systems) for - matching zero or more directory levels and "*" for matching zero or more arbitrary characters with the exception of - any path separator. Wrap meta-characters in brackets for a literal match (i.e. "[?]" to match the literal character - "?"). + The pattern may include ``**`` ( stands for the platform-specific path separator; "/" on POSIX systems) + for matching zero or more directory levels and "*" for matching zero or more arbitrary characters except any path + separator. Wrap meta-characters in brackets for a literal match (i.e. "[?]" to match the literal character "?"). Using match_end=regex one can give a regular expression that is used to match after the regex that is generated from the pattern. The default is to match the end of the string. diff --git a/src/borg/manifest.py b/src/borg/manifest.py index 189caf6a..592b5319 100644 --- a/src/borg/manifest.py +++ b/src/borg/manifest.py @@ -164,7 +164,8 @@ class Archives(abc.MutableMapping): consider_checkpoints = getattr(args, "consider_checkpoints", None) if name is not None: raise Error( - "Giving a specific name is incompatible with options --first, --last, -a / --match-archives, and --consider-checkpoints." + "Giving a specific name is incompatible with options --first, --last, " + "-a / --match-archives, and --consider-checkpoints." ) return self.list( sort_by=args.sort_by.split(","), diff --git a/src/borg/remote.py b/src/borg/remote.py index 0bc97786..40b8b62f 100644 --- a/src/borg/remote.py +++ b/src/borg/remote.py @@ -108,7 +108,7 @@ class UnexpectedRPCDataFormatFromServer(Error): # All method calls on the remote repository object must be allowlisted in RepositoryServer.rpc_methods and have api # stubs in RemoteRepository. The @api decorator on these stubs is used to set server version requirements. # -# Method parameters are identified only by name and never by position. Unknown parameters are ignored by the server side. +# Method parameters are identified only by name and never by position. Unknown parameters are ignored by the server. # If a new parameter is important and may not be ignored, on the client a parameter specific version requirement needs # to be added. # When parameters are removed, they need to be preserved as defaulted parameters on the client stubs so that older diff --git a/src/borg/repository.py b/src/borg/repository.py index c4b0f810..673cf758 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -881,13 +881,15 @@ class Repository: # # Now we crash. But only segment 2 gets deleted, while segment 1 is still around. Now key 1 # is suddenly undeleted (because the delete in segment 2 is now missing). - # Again, note the requirement here. We delete these in the correct order that this doesn't happen, - # and only if the FS materialization of these deletes is reordered or parts dropped this can happen. - # In this case it doesn't cause outright corruption, 'just' an index count mismatch, which will be - # fixed by borg-check --repair. + # Again, note the requirement here. We delete these in the correct order that this doesn't + # happen, and only if the FS materialization of these deletes is reordered or parts dropped + # this can happen. + # In this case it doesn't cause outright corruption, 'just' an index count mismatch, which + # will be fixed by borg-check --repair. # - # Note that in this check the index state is the proxy for a "most definitely settled" repository state, - # i.e. the assumption is that *all* operations on segments <= index state are completed and stable. + # Note that in this check the index state is the proxy for a "most definitely settled" + # repository state, i.e. the assumption is that *all* operations on segments <= index state + # are completed and stable. try: new_segment, size = self.io.write_delete(key, raise_full=True) except LoggedIO.SegmentFull: diff --git a/src/borg/testsuite/crypto.py b/src/borg/testsuite/crypto.py index 88386946..4e031899 100644 --- a/src/borg/testsuite/crypto.py +++ b/src/borg/testsuite/crypto.py @@ -315,7 +315,8 @@ def test_repo_key_detect_does_not_raise_integrity_error(getpass, monkeypatch): This is a regression test for a bug I introduced and fixed: Traceback (most recent call last): - File "/home/user/borg-master/src/borg/testsuite/crypto.py", line 384, in test_repo_key_detect_does_not_raise_integrity_error + File "/home/user/borg-master/src/borg/testsuite/crypto.py", line 384, + in test_repo_key_detect_does_not_raise_integrity_error RepoKey.detect(repository, manifest_data=None) File "/home/user/borg-master/src/borg/crypto/key.py", line 402, in detect if not key.load(target, passphrase): @@ -335,7 +336,8 @@ def test_repo_key_detect_does_not_raise_integrity_error(getpass, monkeypatch): 1. FlexiKey.decrypt_key_file() is supposed to signal the decryption failure by returning None 2. FlexiKey.detect() relies on that interface - it tries an empty passphrase before prompting the user - 3. my initial implementation of decrypt_key_file_argon2() was simply passing through the IntegrityError() from AES256_CTR_BASE.decrypt() + 3. my initial implementation of decrypt_key_file_argon2() was simply passing through the IntegrityError() + from AES256_CTR_BASE.decrypt() """ repository = MagicMock(id=b"repository_id") getpass.return_value = "hello, pass phrase" diff --git a/src/borg/testsuite/helpers.py b/src/borg/testsuite/helpers.py index 03070802..aee14239 100644 --- a/src/borg/testsuite/helpers.py +++ b/src/borg/testsuite/helpers.py @@ -178,11 +178,13 @@ class TestLocationWithoutEnv: ) assert ( repr(Location("ssh://user@[2a02:0001:0002:0003:0004:0005:0006:0007]/some/path")) - == "Location(proto='ssh', user='user', host='2a02:0001:0002:0003:0004:0005:0006:0007', port=None, path='/some/path')" + == "Location(proto='ssh', user='user', " + "host='2a02:0001:0002:0003:0004:0005:0006:0007', port=None, path='/some/path')" ) assert ( repr(Location("ssh://user@[2a02:0001:0002:0003:0004:0005:0006:0007]:1234/some/path")) - == "Location(proto='ssh', user='user', host='2a02:0001:0002:0003:0004:0005:0006:0007', port=1234, path='/some/path')" + == "Location(proto='ssh', user='user', " + "host='2a02:0001:0002:0003:0004:0005:0006:0007', port=1234, path='/some/path')" ) def test_socket(self, monkeypatch, keys_dir): diff --git a/src/borg/testsuite/locking.py b/src/borg/testsuite/locking.py index 5010f164..ea1bdb5f 100644 --- a/src/borg/testsuite/locking.py +++ b/src/borg/testsuite/locking.py @@ -148,19 +148,19 @@ class TestExclusiveLock: while not timer.timed_out(): cycle += 1 try: - with ExclusiveLock( - lockpath, id=id, timeout=timeout / 20, sleep=-1 - ): # This timeout is only for not exceeding the given timeout by more than 5%. With sleep<0 it's constantly polling anyway. + # This timeout is only for not exceeding the given timeout by more than 5%. + # With sleep<0 it's constantly polling anyway. + with ExclusiveLock(lockpath, id=id, timeout=timeout / 20, sleep=-1): lock_owner_count = lock_owner_counter.incr() print_locked( - "Thread %2d: Acquired the lock. It's my %d. loop cycle. I am the %d. who has the lock concurrently." - % (thread_id, cycle, lock_owner_count) + "Thread %2d: Acquired the lock. It's my %d. loop cycle. " + "I am the %d. who has the lock concurrently." % (thread_id, cycle, lock_owner_count) ) time.sleep(0.005) lock_owner_count = lock_owner_counter.decr() print_locked( - "Thread %2d: Releasing the lock, finishing my %d. loop cycle. Currently, %d colleagues still have the lock." - % (thread_id, cycle, lock_owner_count) + "Thread %2d: Releasing the lock, finishing my %d. loop cycle. " + "Currently, %d colleagues still have the lock." % (thread_id, cycle, lock_owner_count) ) except LockTimeout: print_locked("Thread %2d: Got LockTimeout, finishing my %d. loop cycle." % (thread_id, cycle)) @@ -168,8 +168,8 @@ class TestExclusiveLock: exception_count = exception_counter.incr() e = format_exc() print_locked( - "Thread %2d: Exception thrown, finishing my %d. loop cycle. It's the %d. exception seen until now: %s" - % (thread_id, cycle, exception_count, e) + "Thread %2d: Exception thrown, finishing my %d. loop cycle. " + "It's the %d. exception seen until now: %s" % (thread_id, cycle, exception_count, e) ) print_locked("Thread %2d: Loop timed out--terminating after %d loop cycles." % (thread_id, cycle)) diff --git a/src/borg/testsuite/platform.py b/src/borg/testsuite/platform.py index f1de49de..14f8bed4 100644 --- a/src/borg/testsuite/platform.py +++ b/src/borg/testsuite/platform.py @@ -186,7 +186,9 @@ class PlatformDarwinTestCase(BaseTestCase): self.assert_equal(self.get_acl(file.name), {}) self.set_acl( file.name, - b"!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n", + b"!#acl 1\n" + b"group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\n" + b"user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n", numeric_ids=False, ) self.assert_in( @@ -197,7 +199,9 @@ class PlatformDarwinTestCase(BaseTestCase): ) self.set_acl( file2.name, - b"!#acl 1\ngroup:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\nuser:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n", + b"!#acl 1\n" + b"group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000000:staff:0:allow:read\n" + b"user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000:root:0:allow:read\n", numeric_ids=True, ) self.assert_in(