mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Remove superfluous exception parens
This commit is contained in:
parent
defe8e2591
commit
24cb49f64c
21 changed files with 47 additions and 46 deletions
|
|
@ -76,7 +76,7 @@ def github_issue_role(name, rawtext, text, lineno, inliner, options=None, conten
|
||||||
try:
|
try:
|
||||||
issue_num = int(text)
|
issue_num = int(text)
|
||||||
if issue_num <= 0:
|
if issue_num <= 0:
|
||||||
raise ValueError()
|
raise ValueError
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = inliner.reporter.error(f"Invalid GitHub issue: {text}", line=lineno)
|
msg = inliner.reporter.error(f"Invalid GitHub issue: {text}", line=lineno)
|
||||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ select = [
|
||||||
"UP",
|
"UP",
|
||||||
"C4",
|
"C4",
|
||||||
# "TID",
|
# "TID",
|
||||||
|
"RSE"
|
||||||
]
|
]
|
||||||
target-version = "py37"
|
target-version = "py37"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class StorageTests:
|
||||||
|
|
||||||
:param collection: The name of the collection to create and use.
|
:param collection: The name of the collection to create and use.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def s(self, get_storage_args):
|
async def s(self, get_storage_args):
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class ServerMixin:
|
||||||
elif self.storage_class.fileext == ".vcf":
|
elif self.storage_class.fileext == ".vcf":
|
||||||
pytest.skip("No carddav")
|
pytest.skip("No carddav")
|
||||||
else:
|
else:
|
||||||
raise RuntimeError()
|
raise RuntimeError
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def get_storage_args(self, davical_args, request):
|
def get_storage_args(self, davical_args, request):
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class ServerMixin:
|
||||||
elif self.storage_class.fileext == ".vcf":
|
elif self.storage_class.fileext == ".vcf":
|
||||||
args["url"] = "https://carddav.fastmail.com/"
|
args["url"] = "https://carddav.fastmail.com/"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError()
|
raise RuntimeError
|
||||||
|
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
args = await slow_create_collection(
|
args = await slow_create_collection(
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class ServerMixin:
|
||||||
elif self.storage_class.fileext == ".vcf":
|
elif self.storage_class.fileext == ".vcf":
|
||||||
args["url"] = "https://contacts.icloud.com/"
|
args["url"] = "https://contacts.icloud.com/"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError()
|
raise RuntimeError
|
||||||
|
|
||||||
if collection is not None:
|
if collection is not None:
|
||||||
args = slow_create_collection(self.storage_class, args, collection)
|
args = slow_create_collection(self.storage_class, args, collection)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class TestFilesystemStorage(StorageTests):
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_post_hook_inactive(self, tmpdir, monkeypatch):
|
async def test_post_hook_inactive(self, tmpdir, monkeypatch):
|
||||||
def check_call_mock(*args, **kwargs):
|
def check_call_mock(*args, **kwargs):
|
||||||
raise AssertionError()
|
raise AssertionError
|
||||||
|
|
||||||
monkeypatch.setattr(subprocess, "call", check_call_mock)
|
monkeypatch.setattr(subprocess, "call", check_call_mock)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class CombinedStorage(Storage):
|
||||||
|
|
||||||
def __init__(self, url, path, *, connector, **kwargs):
|
def __init__(self, url, path, *, connector, **kwargs):
|
||||||
if kwargs.get("collection", None) is not None:
|
if kwargs.get("collection", None) is not None:
|
||||||
raise ValueError()
|
raise ValueError
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
|
||||||
|
|
@ -207,13 +207,13 @@ def test_collection_required(a_requires, b_requires, tmpdir, runner, monkeypatch
|
||||||
def __init__(self, require_collection, **kw):
|
def __init__(self, require_collection, **kw):
|
||||||
if require_collection:
|
if require_collection:
|
||||||
assert not kw.get("collection")
|
assert not kw.get("collection")
|
||||||
raise exceptions.CollectionRequired()
|
raise exceptions.CollectionRequired
|
||||||
|
|
||||||
async def get(self, href: str):
|
async def get(self, href: str):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
async def list(self) -> List[tuple]:
|
async def list(self) -> List[tuple]:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
from vdirsyncer.cli.utils import storage_names
|
from vdirsyncer.cli.utils import storage_names
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ def test_failed_strategy(monkeypatch, value_cache):
|
||||||
|
|
||||||
def strategy(x):
|
def strategy(x):
|
||||||
calls.append(x)
|
calls.append(x)
|
||||||
raise KeyboardInterrupt()
|
raise KeyboardInterrupt
|
||||||
|
|
||||||
monkeypatch.setitem(STRATEGIES, "mystrategy", strategy)
|
monkeypatch.setitem(STRATEGIES, "mystrategy", strategy)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,7 @@ class ActionIntentionallyFailed(Exception):
|
||||||
|
|
||||||
|
|
||||||
def action_failure(*a, **kw):
|
def action_failure(*a, **kw):
|
||||||
raise ActionIntentionallyFailed()
|
raise ActionIntentionallyFailed
|
||||||
|
|
||||||
|
|
||||||
class SyncMachine(RuleBasedStateMachine):
|
class SyncMachine(RuleBasedStateMachine):
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ def _fetch_value(opts, key):
|
||||||
try:
|
try:
|
||||||
ctx = click.get_current_context().find_object(AppContext)
|
ctx = click.get_current_context().find_object(AppContext)
|
||||||
if ctx is None:
|
if ctx is None:
|
||||||
raise RuntimeError()
|
raise RuntimeError
|
||||||
password_cache = ctx.fetched_params
|
password_cache = ctx.fetched_params
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
password_cache = {}
|
password_cache = {}
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,12 @@ async def sync_collection(
|
||||||
)
|
)
|
||||||
|
|
||||||
if sync_failed:
|
if sync_failed:
|
||||||
raise JobFailed()
|
raise JobFailed
|
||||||
except JobFailed:
|
except JobFailed:
|
||||||
raise
|
raise
|
||||||
except BaseException:
|
except BaseException:
|
||||||
handle_cli_error(status_name)
|
handle_cli_error(status_name)
|
||||||
raise JobFailed()
|
raise JobFailed
|
||||||
|
|
||||||
|
|
||||||
async def discover_collections(pair, **kwargs):
|
async def discover_collections(pair, **kwargs):
|
||||||
|
|
@ -161,7 +161,7 @@ async def metasync_collection(collection, general, *, connector: aiohttp.TCPConn
|
||||||
)
|
)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
handle_cli_error(status_name)
|
handle_cli_error(status_name)
|
||||||
raise JobFailed()
|
raise JobFailed
|
||||||
|
|
||||||
save_status(
|
save_status(
|
||||||
general["status_path"],
|
general["status_path"],
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ async def repair_storage(storage, repair_unsafe_uid):
|
||||||
|
|
||||||
def repair_item(href, item, seen_uids, repair_unsafe_uid):
|
def repair_item(href, item, seen_uids, repair_unsafe_uid):
|
||||||
if item.parsed is None:
|
if item.parsed is None:
|
||||||
raise IrreparableItem()
|
raise IrreparableItem
|
||||||
|
|
||||||
new_item = item
|
new_item = item
|
||||||
|
|
||||||
|
|
@ -62,6 +62,6 @@ def repair_item(href, item, seen_uids, repair_unsafe_uid):
|
||||||
new_item = item.with_uid(generate_href())
|
new_item = item.with_uid(generate_href())
|
||||||
|
|
||||||
if not new_item.uid:
|
if not new_item.uid:
|
||||||
raise IrreparableItem()
|
raise IrreparableItem
|
||||||
|
|
||||||
return new_item
|
return new_item
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class Storage(metaclass=StorageMeta):
|
||||||
"""
|
"""
|
||||||
if False:
|
if False:
|
||||||
yield # Needs to be an async generator
|
yield # Needs to be an async generator
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def create_collection(cls, collection, **kwargs):
|
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.
|
The returned args should contain the collection name, for UI purposes.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
try:
|
try:
|
||||||
|
|
@ -184,7 +184,7 @@ class Storage(metaclass=StorageMeta):
|
||||||
|
|
||||||
:returns: (href, etag)
|
:returns: (href, etag)
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
async def update(self, href: str, item: Item, etag):
|
async def update(self, href: str, item: Item, etag):
|
||||||
"""Update an item.
|
"""Update an item.
|
||||||
|
|
@ -197,7 +197,7 @@ class Storage(metaclass=StorageMeta):
|
||||||
|
|
||||||
:returns: etag
|
:returns: etag
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
async def delete(self, href: str, etag: str):
|
async def delete(self, href: str, etag: str):
|
||||||
"""Delete an item by href.
|
"""Delete an item by href.
|
||||||
|
|
@ -205,7 +205,7 @@ class Storage(metaclass=StorageMeta):
|
||||||
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` when item has
|
:raises: :exc:`vdirsyncer.exceptions.PreconditionFailed` when item has
|
||||||
a different etag or doesn't exist.
|
a different etag or doesn't exist.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@contextlib.asynccontextmanager
|
@contextlib.asynccontextmanager
|
||||||
async def at_once(self):
|
async def at_once(self):
|
||||||
|
|
|
||||||
|
|
@ -690,7 +690,7 @@ class DAVStorage(Storage):
|
||||||
try:
|
try:
|
||||||
tagname, namespace = self._property_table[key]
|
tagname, namespace = self._property_table[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise exceptions.UnsupportedMetadataError()
|
raise exceptions.UnsupportedMetadataError
|
||||||
|
|
||||||
xpath = f"{{{namespace}}}{tagname}"
|
xpath = f"{{{namespace}}}{tagname}"
|
||||||
body = f"""<?xml version="1.0" encoding="utf-8" ?>
|
body = f"""<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|
@ -724,7 +724,7 @@ class DAVStorage(Storage):
|
||||||
try:
|
try:
|
||||||
tagname, namespace = self._property_table[key]
|
tagname, namespace = self._property_table[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise exceptions.UnsupportedMetadataError()
|
raise exceptions.UnsupportedMetadataError
|
||||||
|
|
||||||
lxml_selector = f"{{{namespace}}}{tagname}"
|
lxml_selector = f"{{{namespace}}}{tagname}"
|
||||||
element = etree.Element(lxml_selector)
|
element = etree.Element(lxml_selector)
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ class GoogleCalendarStorage(dav.CalDAVStorage):
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if not kwargs.get("collection"):
|
if not kwargs.get("collection"):
|
||||||
raise exceptions.CollectionRequired()
|
raise exceptions.CollectionRequired
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
token_file=token_file,
|
token_file=token_file,
|
||||||
|
|
@ -228,7 +228,7 @@ class GoogleContactsStorage(dav.CardDAVStorage):
|
||||||
|
|
||||||
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
||||||
if not kwargs.get("collection"):
|
if not kwargs.get("collection"):
|
||||||
raise exceptions.CollectionRequired()
|
raise exceptions.CollectionRequired
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
token_file=token_file,
|
token_file=token_file,
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class SingleFileStorage(Storage):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# If not exactly one '%s' is present, we cannot discover
|
# If not exactly one '%s' is present, we cannot discover
|
||||||
# collections because we wouldn't know which name to assign.
|
# collections because we wouldn't know which name to assign.
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
placeholder_pos = path.index("%s")
|
placeholder_pos = path.index("%s")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ async def sync(
|
||||||
- ``revert`` (default): Revert changes on other side.
|
- ``revert`` (default): Revert changes on other side.
|
||||||
"""
|
"""
|
||||||
if storage_a.read_only and storage_b.read_only:
|
if storage_a.read_only and storage_b.read_only:
|
||||||
raise BothReadOnly()
|
raise BothReadOnly
|
||||||
|
|
||||||
if conflict_resolution == "a wins":
|
if conflict_resolution == "a wins":
|
||||||
conflict_resolution = lambda a, b: a # noqa: E731
|
conflict_resolution = lambda a, b: a # noqa: E731
|
||||||
|
|
@ -165,7 +165,7 @@ async def sync(
|
||||||
|
|
||||||
class Action:
|
class Action:
|
||||||
async def _run_impl(self, a, b): # pragma: no cover
|
async def _run_impl(self, a, b): # pragma: no cover
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
async def run(self, a, b, conflict_resolution, partial_sync):
|
async def run(self, a, b, conflict_resolution, partial_sync):
|
||||||
with self.auto_rollback(a, b):
|
with self.auto_rollback(a, b):
|
||||||
|
|
|
||||||
|
|
@ -47,63 +47,63 @@ class _StatusBase(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def transaction(self):
|
def transaction(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def insert_ident_a(self, ident, props):
|
def insert_ident_a(self, ident, props):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def insert_ident_b(self, ident, props):
|
def insert_ident_b(self, ident, props):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def update_ident_a(self, ident, props):
|
def update_ident_a(self, ident, props):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def update_ident_b(self, ident, props):
|
def update_ident_b(self, ident, props):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def remove_ident(self, ident):
|
def remove_ident(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_a(self, ident):
|
def get_a(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_b(self, ident):
|
def get_b(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_new_a(self, ident):
|
def get_new_a(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_new_b(self, ident):
|
def get_new_b(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def iter_old(self):
|
def iter_old(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def iter_new(self):
|
def iter_new(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_by_href_a(self, href, default=(None, None)):
|
def get_by_href_a(self, href, default=(None, None)):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_by_href_b(self, href, default=(None, None)):
|
def get_by_href_b(self, href, default=(None, None)):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def rollback(self, ident):
|
def rollback(self, ident):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class SqliteStatus(_StatusBase):
|
class SqliteStatus(_StatusBase):
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ class _Component:
|
||||||
rv = line[len(prefix_with_params) :].split(":", 1)[-1]
|
rv = line[len(prefix_with_params) :].split(":", 1)[-1]
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise KeyError()
|
raise KeyError
|
||||||
|
|
||||||
for line in iterlines:
|
for line in iterlines:
|
||||||
if line.startswith((" ", "\t")):
|
if line.startswith((" ", "\t")):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue