From 24cb49f64c58eb9dbed820fce0e7a7371f2d76ca Mon Sep 17 00:00:00 2001 From: Hugo Osvaldo Barrera Date: Fri, 10 Feb 2023 16:57:39 +0100 Subject: [PATCH] Remove superfluous exception parens --- docs/conf.py | 2 +- pyproject.toml | 1 + tests/storage/__init__.py | 2 +- tests/storage/servers/davical/__init__.py | 2 +- tests/storage/servers/fastmail/__init__.py | 2 +- tests/storage/servers/icloud/__init__.py | 2 +- tests/storage/test_filesystem.py | 2 +- tests/storage/test_http_with_singlefile.py | 2 +- tests/system/cli/test_discover.py | 6 ++--- tests/unit/cli/test_fetchparams.py | 2 +- tests/unit/sync/test_sync.py | 2 +- vdirsyncer/cli/fetchparams.py | 2 +- vdirsyncer/cli/tasks.py | 6 ++--- vdirsyncer/repair.py | 4 +-- vdirsyncer/storage/base.py | 10 ++++---- vdirsyncer/storage/dav.py | 4 +-- vdirsyncer/storage/google.py | 4 +-- vdirsyncer/storage/singlefile.py | 2 +- vdirsyncer/sync/__init__.py | 4 +-- vdirsyncer/sync/status.py | 30 +++++++++++----------- vdirsyncer/vobject.py | 2 +- 21 files changed, 47 insertions(+), 46 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index a455fcb..533ddec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -76,7 +76,7 @@ def github_issue_role(name, rawtext, text, lineno, inliner, options=None, conten try: issue_num = int(text) if issue_num <= 0: - raise ValueError() + raise ValueError except ValueError: msg = inliner.reporter.error(f"Invalid GitHub issue: {text}", line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) diff --git a/pyproject.toml b/pyproject.toml index f224bb5..f4ccb24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ select = [ "UP", "C4", # "TID", + "RSE" ] target-version = "py37" diff --git a/tests/storage/__init__.py b/tests/storage/__init__.py index caad26f..cbd6218 100644 --- a/tests/storage/__init__.py +++ b/tests/storage/__init__.py @@ -49,7 +49,7 @@ class StorageTests: :param collection: The name of the collection to create and use. """ - raise NotImplementedError() + raise NotImplementedError @pytest_asyncio.fixture async def s(self, get_storage_args): diff --git a/tests/storage/servers/davical/__init__.py b/tests/storage/servers/davical/__init__.py index d99f50d..abe0669 100644 --- a/tests/storage/servers/davical/__init__.py +++ b/tests/storage/servers/davical/__init__.py @@ -23,7 +23,7 @@ class ServerMixin: elif self.storage_class.fileext == ".vcf": pytest.skip("No carddav") else: - raise RuntimeError() + raise RuntimeError @pytest.fixture def get_storage_args(self, davical_args, request): diff --git a/tests/storage/servers/fastmail/__init__.py b/tests/storage/servers/fastmail/__init__.py index 3233fc8..548aa49 100644 --- a/tests/storage/servers/fastmail/__init__.py +++ b/tests/storage/servers/fastmail/__init__.py @@ -24,7 +24,7 @@ class ServerMixin: elif self.storage_class.fileext == ".vcf": args["url"] = "https://carddav.fastmail.com/" else: - raise RuntimeError() + raise RuntimeError if collection is not None: args = await slow_create_collection( diff --git a/tests/storage/servers/icloud/__init__.py b/tests/storage/servers/icloud/__init__.py index cb7285c..096702c 100644 --- a/tests/storage/servers/icloud/__init__.py +++ b/tests/storage/servers/icloud/__init__.py @@ -22,7 +22,7 @@ class ServerMixin: elif self.storage_class.fileext == ".vcf": args["url"] = "https://contacts.icloud.com/" else: - raise RuntimeError() + raise RuntimeError if collection is not None: args = slow_create_collection(self.storage_class, args, collection) diff --git a/tests/storage/test_filesystem.py b/tests/storage/test_filesystem.py index fb90bdd..9ae6ec0 100644 --- a/tests/storage/test_filesystem.py +++ b/tests/storage/test_filesystem.py @@ -93,7 +93,7 @@ class TestFilesystemStorage(StorageTests): @pytest.mark.asyncio async def test_post_hook_inactive(self, tmpdir, monkeypatch): def check_call_mock(*args, **kwargs): - raise AssertionError() + raise AssertionError monkeypatch.setattr(subprocess, "call", check_call_mock) diff --git a/tests/storage/test_http_with_singlefile.py b/tests/storage/test_http_with_singlefile.py index 7f671d7..3a157ca 100644 --- a/tests/storage/test_http_with_singlefile.py +++ b/tests/storage/test_http_with_singlefile.py @@ -19,7 +19,7 @@ class CombinedStorage(Storage): def __init__(self, url, path, *, connector, **kwargs): if kwargs.get("collection", None) is not None: - raise ValueError() + raise ValueError super().__init__(**kwargs) self.url = url diff --git a/tests/system/cli/test_discover.py b/tests/system/cli/test_discover.py index d47182e..fb9aeac 100644 --- a/tests/system/cli/test_discover.py +++ b/tests/system/cli/test_discover.py @@ -207,13 +207,13 @@ def test_collection_required(a_requires, b_requires, tmpdir, runner, monkeypatch def __init__(self, require_collection, **kw): if require_collection: assert not kw.get("collection") - raise exceptions.CollectionRequired() + raise exceptions.CollectionRequired async def get(self, href: str): - raise NotImplementedError() + raise NotImplementedError async def list(self) -> List[tuple]: - raise NotImplementedError() + raise NotImplementedError from vdirsyncer.cli.utils import storage_names diff --git a/tests/unit/cli/test_fetchparams.py b/tests/unit/cli/test_fetchparams.py index a30bcb3..d3d7229 100644 --- a/tests/unit/cli/test_fetchparams.py +++ b/tests/unit/cli/test_fetchparams.py @@ -106,7 +106,7 @@ def test_failed_strategy(monkeypatch, value_cache): def strategy(x): calls.append(x) - raise KeyboardInterrupt() + raise KeyboardInterrupt monkeypatch.setitem(STRATEGIES, "mystrategy", strategy) diff --git a/tests/unit/sync/test_sync.py b/tests/unit/sync/test_sync.py index 84db2fa..7720d30 100644 --- a/tests/unit/sync/test_sync.py +++ b/tests/unit/sync/test_sync.py @@ -535,7 +535,7 @@ class ActionIntentionallyFailed(Exception): def action_failure(*a, **kw): - raise ActionIntentionallyFailed() + raise ActionIntentionallyFailed class SyncMachine(RuleBasedStateMachine): diff --git a/vdirsyncer/cli/fetchparams.py b/vdirsyncer/cli/fetchparams.py index 7952bc6..2cdcea9 100644 --- a/vdirsyncer/cli/fetchparams.py +++ b/vdirsyncer/cli/fetchparams.py @@ -37,7 +37,7 @@ def _fetch_value(opts, key): try: ctx = click.get_current_context().find_object(AppContext) if ctx is None: - raise RuntimeError() + raise RuntimeError password_cache = ctx.fetched_params except RuntimeError: password_cache = {} diff --git a/vdirsyncer/cli/tasks.py b/vdirsyncer/cli/tasks.py index 09c2ffa..2e38e1b 100644 --- a/vdirsyncer/cli/tasks.py +++ b/vdirsyncer/cli/tasks.py @@ -80,12 +80,12 @@ async def sync_collection( ) if sync_failed: - raise JobFailed() + raise JobFailed except JobFailed: raise except BaseException: handle_cli_error(status_name) - raise JobFailed() + raise JobFailed async def discover_collections(pair, **kwargs): @@ -161,7 +161,7 @@ async def metasync_collection(collection, general, *, connector: aiohttp.TCPConn ) except BaseException: handle_cli_error(status_name) - raise JobFailed() + raise JobFailed save_status( general["status_path"], diff --git a/vdirsyncer/repair.py b/vdirsyncer/repair.py index d3e48dc..e72e480 100644 --- a/vdirsyncer/repair.py +++ b/vdirsyncer/repair.py @@ -42,7 +42,7 @@ async def repair_storage(storage, repair_unsafe_uid): def repair_item(href, item, seen_uids, repair_unsafe_uid): if item.parsed is None: - raise IrreparableItem() + raise IrreparableItem new_item = item @@ -62,6 +62,6 @@ def repair_item(href, item, seen_uids, repair_unsafe_uid): new_item = item.with_uid(generate_href()) if not new_item.uid: - raise IrreparableItem() + raise IrreparableItem return new_item diff --git a/vdirsyncer/storage/base.py b/vdirsyncer/storage/base.py index 62866a1..ee9acdf 100644 --- a/vdirsyncer/storage/base.py +++ b/vdirsyncer/storage/base.py @@ -105,7 +105,7 @@ class Storage(metaclass=StorageMeta): """ if False: yield # Needs to be an async generator - raise NotImplementedError() + raise NotImplementedError @classmethod async def create_collection(cls, collection, **kwargs): @@ -117,7 +117,7 @@ class Storage(metaclass=StorageMeta): The returned args should contain the collection name, for UI purposes. """ - raise NotImplementedError() + raise NotImplementedError def __repr__(self): try: @@ -184,7 +184,7 @@ class Storage(metaclass=StorageMeta): :returns: (href, etag) """ - raise NotImplementedError() + raise NotImplementedError async def update(self, href: str, item: Item, etag): """Update an item. @@ -197,7 +197,7 @@ class Storage(metaclass=StorageMeta): :returns: etag """ - raise NotImplementedError() + raise NotImplementedError async def delete(self, href: str, etag: str): """Delete an item by href. @@ -205,7 +205,7 @@ class Storage(metaclass=StorageMeta): :raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` when item has a different etag or doesn't exist. """ - raise NotImplementedError() + raise NotImplementedError @contextlib.asynccontextmanager async def at_once(self): diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 62b7618..dcaf15e 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -690,7 +690,7 @@ class DAVStorage(Storage): try: tagname, namespace = self._property_table[key] except KeyError: - raise exceptions.UnsupportedMetadataError() + raise exceptions.UnsupportedMetadataError xpath = f"{{{namespace}}}{tagname}" body = f""" @@ -724,7 +724,7 @@ class DAVStorage(Storage): try: tagname, namespace = self._property_table[key] except KeyError: - raise exceptions.UnsupportedMetadataError() + raise exceptions.UnsupportedMetadataError lxml_selector = f"{{{namespace}}}{tagname}" element = etree.Element(lxml_selector) diff --git a/vdirsyncer/storage/google.py b/vdirsyncer/storage/google.py index e3c4557..bc80cee 100644 --- a/vdirsyncer/storage/google.py +++ b/vdirsyncer/storage/google.py @@ -190,7 +190,7 @@ class GoogleCalendarStorage(dav.CalDAVStorage): **kwargs, ): if not kwargs.get("collection"): - raise exceptions.CollectionRequired() + raise exceptions.CollectionRequired super().__init__( token_file=token_file, @@ -228,7 +228,7 @@ class GoogleContactsStorage(dav.CardDAVStorage): def __init__(self, token_file, client_id, client_secret, **kwargs): if not kwargs.get("collection"): - raise exceptions.CollectionRequired() + raise exceptions.CollectionRequired super().__init__( token_file=token_file, diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index 7edfc3a..2297c02 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -65,7 +65,7 @@ class SingleFileStorage(Storage): except TypeError: # If not exactly one '%s' is present, we cannot discover # collections because we wouldn't know which name to assign. - raise NotImplementedError() + raise NotImplementedError placeholder_pos = path.index("%s") diff --git a/vdirsyncer/sync/__init__.py b/vdirsyncer/sync/__init__.py index 379c9c8..8678bc9 100644 --- a/vdirsyncer/sync/__init__.py +++ b/vdirsyncer/sync/__init__.py @@ -128,7 +128,7 @@ async def sync( - ``revert`` (default): Revert changes on other side. """ if storage_a.read_only and storage_b.read_only: - raise BothReadOnly() + raise BothReadOnly if conflict_resolution == "a wins": conflict_resolution = lambda a, b: a # noqa: E731 @@ -165,7 +165,7 @@ async def sync( class Action: async def _run_impl(self, a, b): # pragma: no cover - raise NotImplementedError() + raise NotImplementedError async def run(self, a, b, conflict_resolution, partial_sync): with self.auto_rollback(a, b): diff --git a/vdirsyncer/sync/status.py b/vdirsyncer/sync/status.py index fd51bd0..d0d2c10 100644 --- a/vdirsyncer/sync/status.py +++ b/vdirsyncer/sync/status.py @@ -47,63 +47,63 @@ class _StatusBase(metaclass=abc.ABCMeta): @abc.abstractmethod def transaction(self): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def insert_ident_a(self, ident, props): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def insert_ident_b(self, ident, props): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def update_ident_a(self, ident, props): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def update_ident_b(self, ident, props): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def remove_ident(self, ident): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_a(self, ident): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_b(self, ident): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_new_a(self, ident): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_new_b(self, ident): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def iter_old(self): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def iter_new(self): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_by_href_a(self, href, default=(None, None)): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def get_by_href_b(self, href, default=(None, None)): - raise NotImplementedError() + raise NotImplementedError @abc.abstractmethod def rollback(self, ident): - raise NotImplementedError() + raise NotImplementedError class SqliteStatus(_StatusBase): diff --git a/vdirsyncer/vobject.py b/vdirsyncer/vobject.py index 20998d8..2f18f69 100644 --- a/vdirsyncer/vobject.py +++ b/vdirsyncer/vobject.py @@ -352,7 +352,7 @@ class _Component: rv = line[len(prefix_with_params) :].split(":", 1)[-1] break else: - raise KeyError() + raise KeyError for line in iterlines: if line.startswith((" ", "\t")):