Remove superfluous exception parens

This commit is contained in:
Hugo Osvaldo Barrera 2023-02-10 16:57:39 +01:00
parent defe8e2591
commit 24cb49f64c
21 changed files with 47 additions and 46 deletions

View file

@ -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)

View file

@ -8,6 +8,7 @@ select = [
"UP",
"C4",
# "TID",
"RSE"
]
target-version = "py37"

View file

@ -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):

View file

@ -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):

View file

@ -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(

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -535,7 +535,7 @@ class ActionIntentionallyFailed(Exception):
def action_failure(*a, **kw):
raise ActionIntentionallyFailed()
raise ActionIntentionallyFailed
class SyncMachine(RuleBasedStateMachine):

View file

@ -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 = {}

View file

@ -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"],

View file

@ -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

View file

@ -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):

View file

@ -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"""<?xml version="1.0" encoding="utf-8" ?>
@ -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)

View file

@ -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,

View file

@ -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")

View file

@ -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):

View file

@ -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):

View file

@ -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")):