From 2b4496fea4e1a1f0b2bd77317e4ac0e68be201c3 Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Mon, 7 Apr 2025 18:42:00 +0200 Subject: [PATCH] Update linting tools --- .pre-commit-config.yaml | 6 +++--- contrib/conflict_resolution/resolve_interactively.py | 1 + docs/conf.py | 4 +--- tests/system/cli/test_sync.py | 4 +--- tests/unit/utils/test_vobject.py | 2 +- vdirsyncer/cli/config.py | 2 +- vdirsyncer/cli/discover.py | 3 +-- vdirsyncer/repair.py | 4 +--- vdirsyncer/storage/dav.py | 4 ++-- vdirsyncer/storage/singlefile.py | 2 +- vdirsyncer/utils.py | 2 +- 11 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d19e2a7..851b30f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v5.0.0 hooks: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] @@ -9,7 +9,7 @@ repos: - id: check-added-large-files - id: debug-statements - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.8.0" + rev: "v1.15.0" hooks: - id: mypy files: vdirsyncer/.* @@ -18,7 +18,7 @@ repos: - types-docutils - types-requests - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.2.2' + rev: 'v0.11.4' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/contrib/conflict_resolution/resolve_interactively.py b/contrib/conflict_resolution/resolve_interactively.py index d676496..2c5a775 100755 --- a/contrib/conflict_resolution/resolve_interactively.py +++ b/contrib/conflict_resolution/resolve_interactively.py @@ -16,6 +16,7 @@ SPDX-License-Identifier: BSD-3-Clause SPDX-FileCopyrightText: 2021 Intevation GmbH Author: """ + from __future__ import annotations import re diff --git a/docs/conf.py b/docs/conf.py index 807997b..10cdc91 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,9 +37,7 @@ except ImportError: html_theme = "default" if not on_rtd: print("-" * 74) - print( - "Warning: sphinx-rtd-theme not installed, building with default " "theme." - ) + print("Warning: sphinx-rtd-theme not installed, building with default theme.") print("-" * 74) html_static_path = ["_static"] diff --git a/tests/system/cli/test_sync.py b/tests/system/cli/test_sync.py index 2824be5..77a512a 100644 --- a/tests/system/cli/test_sync.py +++ b/tests/system/cli/test_sync.py @@ -90,9 +90,7 @@ def test_empty_storage(tmpdir, runner): result = runner.invoke(["sync"]) lines = result.output.splitlines() assert lines[0] == "Syncing my_pair" - assert lines[1].startswith( - "error: my_pair: " 'Storage "my_b" was completely emptied.' - ) + assert lines[1].startswith('error: my_pair: Storage "my_b" was completely emptied.') assert result.exception diff --git a/tests/unit/utils/test_vobject.py b/tests/unit/utils/test_vobject.py index 032e4a5..d656129 100644 --- a/tests/unit/utils/test_vobject.py +++ b/tests/unit/utils/test_vobject.py @@ -154,7 +154,7 @@ def test_hash_item(): def test_multiline_uid(benchmark): - a = "BEGIN:FOO\r\n" "UID:123456789abcd\r\n" " efgh\r\n" "END:FOO\r\n" + a = "BEGIN:FOO\r\nUID:123456789abcd\r\n efgh\r\nEND:FOO\r\n" assert benchmark(lambda: vobject.Item(a).uid) == "123456789abcdefgh" diff --git a/vdirsyncer/cli/config.py b/vdirsyncer/cli/config.py index 8aed824..94d7a84 100644 --- a/vdirsyncer/cli/config.py +++ b/vdirsyncer/cli/config.py @@ -359,7 +359,7 @@ def _resolve_conflict_via_command( new_b = f.read() if new_a != new_b: - raise exceptions.UserError("The two files are not completely " "equal.") + raise exceptions.UserError("The two files are not completely equal.") return Item(new_a) finally: shutil.rmtree(dir) diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index 247306e..ebd4e16 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -72,8 +72,7 @@ async def collections_for_pair( ) else: raise exceptions.UserError( - f"Please run `vdirsyncer discover {pair.name}` " - " before synchronization." + f"Please run `vdirsyncer discover {pair.name}` before synchronization." ) logger.info(f"Discovering collections for pair {pair.name}") diff --git a/vdirsyncer/repair.py b/vdirsyncer/repair.py index 7a1116e..d4d831a 100644 --- a/vdirsyncer/repair.py +++ b/vdirsyncer/repair.py @@ -56,9 +56,7 @@ def repair_item(href, item, seen_uids, repair_unsafe_uid): new_item = item.with_uid(generate_href()) elif not href_safe(item.uid) or not href_safe(basename(href)): if not repair_unsafe_uid: - logger.warning( - "UID may cause problems, add " "--repair-unsafe-uid to repair." - ) + logger.warning("UID may cause problems, add --repair-unsafe-uid to repair.") else: logger.warning("UID or href is unsafe, assigning random UID.") new_item = item.with_uid(generate_href()) diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index d5b1da6..b911082 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -261,7 +261,7 @@ class Discover: href = response.find("{DAV:}href") if href is None: - raise InvalidXMLResponse("Missing href tag for collection " "props.") + raise InvalidXMLResponse("Missing href tag for collection props.") href = urlparse.urljoin(str(r.url), href.text) if href not in done: done.add(href) @@ -792,7 +792,7 @@ class CalDAVStorage(DAVStorage): self.item_types = tuple(item_types) if (start_date is None) != (end_date is None): raise exceptions.UserError( - "If start_date is given, " "end_date has to be given too." + "If start_date is given, end_date has to be given too." ) elif start_date is not None and end_date is not None: namespace = dict(datetime.__dict__) diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index 41e7e33..405e7cb 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -94,7 +94,7 @@ class SingleFileStorage(Storage): path = path % (collection,) except TypeError: raise ValueError( - "Exactly one %s required in path " "if collection is not null." + "Exactly one %s required in path if collection is not null." ) checkfile(path, create=True) diff --git a/vdirsyncer/utils.py b/vdirsyncer/utils.py index 7199fc4..b1925c6 100644 --- a/vdirsyncer/utils.py +++ b/vdirsyncer/utils.py @@ -221,7 +221,7 @@ def open_graphical_browser(url, new=0, autoraise=True): if browser.open(url, new, autoraise): return - raise RuntimeError("No graphical browser found. Please open the URL " "manually.") + raise RuntimeError("No graphical browser found. Please open the URL manually.") @contextlib.contextmanager