From fc4a7bc0c90a1790ef83e9a4e6acf2b8422917f4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Oct 2018 11:46:29 +0100 Subject: [PATCH 1/5] flake8: disable the new checks of flake8 3.6 for now --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 40ca52dba..e2dc79ce5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,8 @@ python_files = testsuite/*.py # please note that the values are adjusted so that they do not cause failures # with existing code. if you want to change them, you should first fix all # flake8 failures that appear with your change. -ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741,F401,F405,F811 +ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741,F401,F405,F811, + W504,W605,F841 # line length long term target: 120 max-line-length = 255 exclude = build,dist,.git,.idea,.cache,.tox,docs/conf.py From 10cdadb2f8b33cd6060d9e071fe652f743c7568a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Oct 2018 11:54:24 +0100 Subject: [PATCH 2/5] flake8: fix F841 --- scripts/glibc_check.py | 2 +- setup.cfg | 2 +- src/borg/archive.py | 4 ++-- src/borg/crypto/nonces.py | 2 +- src/borg/testsuite/__init__.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/glibc_check.py b/scripts/glibc_check.py index 02be4aac4..eb198ed56 100755 --- a/scripts/glibc_check.py +++ b/scripts/glibc_check.py @@ -41,7 +41,7 @@ def main(): overall_versions.add(requires_glibc) if verbose: print("%s %s" % (filename, format_version(requires_glibc))) - except subprocess.CalledProcessError as e: + except subprocess.CalledProcessError: if verbose: print("%s errored." % filename) diff --git a/setup.cfg b/setup.cfg index e2dc79ce5..b2da05b43 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ python_files = testsuite/*.py # with existing code. if you want to change them, you should first fix all # flake8 failures that appear with your change. ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741,F401,F405,F811, - W504,W605,F841 + W504,W605 # line length long term target: 120 max-line-length = 255 exclude = build,dist,.git,.idea,.cache,.tox,docs/conf.py diff --git a/src/borg/archive.py b/src/borg/archive.py index c22a655f7..cf8976428 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -758,7 +758,7 @@ Utilization of max. archive size: {csize_max:.0%} def fetch_async_response(wait=True): try: return self.repository.async_response(wait=wait) - except Repository.ObjectNotFound as e: + except Repository.ObjectNotFound: nonlocal error # object not in repo - strange, but we wanted to delete it anyway. if forced == 0: @@ -1627,7 +1627,7 @@ class ArchiveChecker: yield Item(internal_dict=item) else: report('Did not get expected metadata dict when unpacking item metadata (%s)' % reason, chunk_id, i) - except msgpack.UnpackException as err: + except msgpack.UnpackException: report('Unpacker crashed while unpacking item metadata, trying to resync...', chunk_id, i) unpacker.resync() except Exception: diff --git a/src/borg/crypto/nonces.py b/src/borg/crypto/nonces.py index 39ec3d723..fe5abc547 100644 --- a/src/borg/crypto/nonces.py +++ b/src/borg/crypto/nonces.py @@ -36,7 +36,7 @@ class NonceManager: def get_repo_free_nonce(self): try: return self.repository.get_free_nonce() - except InvalidRPCMethod as error: + except InvalidRPCMethod: # old server version, suppress further calls sys.stderr.write("Please upgrade to borg version 1.1+ on the server for safer AES-CTR nonce handling.\n") self.get_repo_free_nonce = lambda: None diff --git a/src/borg/testsuite/__init__.py b/src/borg/testsuite/__init__.py index 465e24fa1..caa7d2a22 100644 --- a/src/borg/testsuite/__init__.py +++ b/src/borg/testsuite/__init__.py @@ -111,7 +111,7 @@ def is_utime_fully_supported(): new_stats = os.stat(filepath, follow_symlinks=False) if new_stats.st_atime == 1000 and new_stats.st_mtime == 2000: return True - except OSError as err: + except OSError: pass return False @@ -133,7 +133,7 @@ def is_birthtime_fully_supported(): new_stats = os.stat(filepath, follow_symlinks=False) if new_stats.st_birthtime == birthtime and new_stats.st_mtime == mtime and new_stats.st_atime == atime: return True - except OSError as err: + except OSError: pass return False From 5c66a60f799d3e20510cc03e2ebad4921464a0fd Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Oct 2018 12:27:56 +0100 Subject: [PATCH 3/5] flake8: fix W605 (invalid escape sequences) --- setup.cfg | 2 +- src/borg/archiver.py | 12 ++++++------ src/borg/helpers/parseformat.py | 4 ++-- src/borg/testsuite/key.py | 2 +- src/borg/testsuite/patterns.py | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/setup.cfg b/setup.cfg index b2da05b43..64514cfc9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ python_files = testsuite/*.py # with existing code. if you want to change them, you should first fix all # flake8 failures that appear with your change. ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741,F401,F405,F811, - W504,W605 + W504 # line length long term target: 120 max-line-length = 255 exclude = build,dist,.git,.idea,.cache,.tox,docs/conf.py diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 2a775fe5a..59ac485e4 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -1978,7 +1978,7 @@ class Archiver: `Fnmatch `_, selector `fm:` This is the default style for ``--exclude`` and ``--exclude-from``. - These patterns use a variant of shell pattern syntax, with '\*' matching + These patterns use a variant of shell pattern syntax, with '\\*' matching any number of characters, '?' matching any single character, '[...]' matching any single character specified, including ranges, and '[!...]' matching any character not specified. For the purpose of these patterns, @@ -1989,7 +1989,7 @@ class Archiver: from the start of the full path to just before a path separator. Except for the root path, paths will never end in the path separator when matching is attempted. Thus, if a given pattern ends in a path - separator, a '\*' is appended before matching is attempted. + separator, a '\\*' is appended before matching is attempted. Shell-style patterns, selector `sh:` This is the default style for ``--pattern`` and ``--patterns-from``. @@ -2064,7 +2064,7 @@ class Archiver: # The contents of directories in '/home' are not backed up when their name # ends in '.tmp' - $ borg create --exclude 're:^/home/[^/]+\.tmp/' backup / + $ borg create --exclude 're:^/home/[^/]+\\.tmp/' backup / # Load exclusions from file $ cat >exclude.txt < 100: # Limit file names to some reasonable length. Most file systems # limit them to 255 [unit of choice]; due to variations in unicode diff --git a/src/borg/testsuite/key.py b/src/borg/testsuite/key.py index 1046e1ad1..1d6281056 100644 --- a/src/borg/testsuite/key.py +++ b/src/borg/testsuite/key.py @@ -35,7 +35,7 @@ class TestKey: /cXJq7jrqmrJ1phd6dg4SHAM/i+hubadZoS6m25OQzYAW09wZD/phG8OVa698Z5ed3HTaT SmrtgJL3EoOKgUI9d6BLE4dJdBqntifo""".strip() - keyfile2_cdata = unhexlify(re.sub('\W', '', """ + keyfile2_cdata = unhexlify(re.sub(r'\W', '', """ 0055f161493fcfc16276e8c31493c4641e1eb19a79d0326fad0291e5a9c98e5933 00000000000003e8d21eaf9b86c297a8cd56432e1915bb """)) diff --git a/src/borg/testsuite/patterns.py b/src/borg/testsuite/patterns.py index ff447888f..5806ff69b 100644 --- a/src/borg/testsuite/patterns.py +++ b/src/borg/testsuite/patterns.py @@ -229,13 +229,13 @@ def test_invalid_unicode_pattern(pattern): "", "# EOF"], ["/more/data", "/home", " #/wsfoobar"]), - (["re:.*"], []), - (["re:\s"], ["/data/something00.txt", "/more/data", "/home"]), + ([r"re:.*"], []), + ([r"re:\s"], ["/data/something00.txt", "/more/data", "/home"]), ([r"re:(.)(\1)"], ["/more/data", "/home", "\tstart/whitespace", "/whitespace/end\t"]), (["", "", "", "# This is a test with mixed pattern styles", # Case-insensitive pattern - "re:(?i)BAR|ME$", + r"re:(?i)BAR|ME$", "", "*whitespace*", "fm:*/something00*"], From b0afc6709bf7e0b98b7d06d201302d655409ae69 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Oct 2018 12:29:44 +0100 Subject: [PATCH 4/5] flake8: use separate lines for different classes of flake8 ignores --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 64514cfc9..c283992b3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,8 @@ python_files = testsuite/*.py # please note that the values are adjusted so that they do not cause failures # with existing code. if you want to change them, you should first fix all # flake8 failures that appear with your change. -ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741,F401,F405,F811, +ignore = E122,E123,E125,E126,E127,E128,E226,E402,E722,E731,E741, + F401,F405,F811, W504 # line length long term target: 120 max-line-length = 255 From 64a53ba43ae60ed746a1c68e243516456fb13128 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 29 Oct 2018 13:53:40 +0100 Subject: [PATCH 5/5] fixup: the help text is parsed as rst markup, so a lone * is an error * and ** are interpreted as emphasis and need to be matched for begin and end of emphasis. the \ in front of it is to get a non-markup *. --- src/borg/archiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 59ac485e4..1afd0a197 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -4074,7 +4074,7 @@ class Archiver: It creates input data below the given PATH and backups this data into the given REPO. The REPO must already exist (it could be a fresh empty repo or an existing repo, the - command will create / read / update / delete some archives named borg-test-data* there. + command will create / read / update / delete some archives named borg-test-data\\* there. Make sure you have free space there, you'll need about 1GB each (+ overhead).