diff --git a/vdirsyncer/cli/discover.py b/vdirsyncer/cli/discover.py index 52b132f..e41cd6f 100644 --- a/vdirsyncer/cli/discover.py +++ b/vdirsyncer/cli/discover.py @@ -95,7 +95,7 @@ async def collections_for_pair( # We have to use a list here because the special None/null value would get # mangled to string (because JSON objects always have string keys). - rv = await aiostream.stream.list( + rv = await aiostream.stream.list( # type: ignore[assignment] expand_collections( shortcuts=pair.collections, config_a=pair.config_a, diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index 03755f3..2ff38d2 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -31,7 +31,7 @@ STATUS_DIR_PERMISSIONS = 0o700 class _StorageIndex: - def __init__(self): + def __init__(self) -> None: self._storages: dict[str, str] = { "caldav": "vdirsyncer.storage.dav.CalDAVStorage", "carddav": "vdirsyncer.storage.dav.CardDAVStorage", diff --git a/vdirsyncer/storage/base.py b/vdirsyncer/storage/base.py index 929c59e..efa1ab2 100644 --- a/vdirsyncer/storage/base.py +++ b/vdirsyncer/storage/base.py @@ -150,7 +150,7 @@ class Storage(metaclass=StorageMeta): """ @abstractmethod - async def get(self, href: str): + async def get(self, href: str) -> tuple[Item, str]: """Fetch a single item. :param href: href to fetch diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index 9402617..6728315 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -497,8 +497,12 @@ class DAVStorage(Storage): def _is_item_mimetype(self, mimetype): return _fuzzy_matches_mimetype(self.item_mimetype, mimetype) - async def get(self, href: str): - ((actual_href, item, etag),) = await aiostream.stream.list( + async def get(self, href: str) -> tuple[Item, str]: + actual_href: str + item: Item + etag: str + + ((actual_href, item, etag),) = await aiostream.stream.list( # type: ignore[misc] self.get_multi([href]) ) assert href == actual_href diff --git a/vdirsyncer/storage/filesystem.py b/vdirsyncer/storage/filesystem.py index c650f6a..0fe1912 100644 --- a/vdirsyncer/storage/filesystem.py +++ b/vdirsyncer/storage/filesystem.py @@ -98,7 +98,7 @@ class FilesystemStorage(Storage): ): yield fname, get_etag_from_file(fpath) - async def get(self, href): + async def get(self, href) -> tuple[Item, str]: fpath = self._get_filepath(href) try: with open(fpath, "rb") as f: diff --git a/vdirsyncer/storage/http.py b/vdirsyncer/storage/http.py index a0e3289..fe74f13 100644 --- a/vdirsyncer/storage/http.py +++ b/vdirsyncer/storage/http.py @@ -117,11 +117,12 @@ class HttpStorage(Storage): for href, (_, etag) in self._items.items(): yield href, etag - async def get(self, href): + async def get(self, href) -> tuple[Item, str]: if self._items is None: async for _ in self.list(): pass + assert self._items is not None # type assertion try: return self._items[href] except KeyError: diff --git a/vdirsyncer/storage/memory.py b/vdirsyncer/storage/memory.py index 9a8b869..04cde06 100644 --- a/vdirsyncer/storage/memory.py +++ b/vdirsyncer/storage/memory.py @@ -3,6 +3,7 @@ from __future__ import annotations import random from vdirsyncer import exceptions +from vdirsyncer.vobject import Item from .base import Storage from .base import normalize_meta_value @@ -34,7 +35,7 @@ class MemoryStorage(Storage): for href, (etag, _item) in self.items.items(): yield href, etag - async def get(self, href): + async def get(self, href) -> tuple[Item, str]: etag, item = self.items[href] return item, etag diff --git a/vdirsyncer/storage/singlefile.py b/vdirsyncer/storage/singlefile.py index f22bacd..a5b8ac2 100644 --- a/vdirsyncer/storage/singlefile.py +++ b/vdirsyncer/storage/singlefile.py @@ -133,11 +133,12 @@ class SingleFileStorage(Storage): yield href, etag - async def get(self, href): + async def get(self, href) -> tuple[Item, str]: if self._items is None or not self._at_once: async for _ in self.list(): pass + assert self._items is not None # type assertion try: return self._items[href] except KeyError: