mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-07 18:30:54 +00:00
- Linting
This commit is contained in:
parent
070ba2d603
commit
c61cbdf3c1
6 changed files with 20 additions and 15 deletions
|
@ -249,7 +249,7 @@ class ApplicationPartPut(ApplicationBase):
|
|||
props=props)
|
||||
for item in prepared_items:
|
||||
# Try to grab the previously-existing item by href
|
||||
existing_item = replaced_items.get(item.href, None)
|
||||
existing_item = replaced_items.get(item.href, None) # type: ignore
|
||||
if existing_item:
|
||||
hook_notification_item = HookNotificationItem(
|
||||
notification_item_type=HookNotificationItemTypes.UPSERT,
|
||||
|
|
|
@ -17,7 +17,8 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple
|
|||
|
||||
import vobject
|
||||
|
||||
from radicale.hook import (BaseHook, HookNotificationItem, HookNotificationItemTypes)
|
||||
from radicale.hook import (BaseHook, HookNotificationItem,
|
||||
HookNotificationItemTypes)
|
||||
from radicale.log import logger
|
||||
|
||||
PLUGIN_CONFIG_SCHEMA = {
|
||||
|
@ -962,7 +963,7 @@ class Hook(BaseHook):
|
|||
return
|
||||
|
||||
# Dealing with an update to an existing event, compare new and previous content.
|
||||
new_event: Event = read_ics_event(contents=new_item_str)
|
||||
new_event: Event = read_ics_event(contents=new_item_str) # type: ignore
|
||||
previous_event: Optional[Event] = read_ics_event(contents=previous_item_str)
|
||||
if not previous_event:
|
||||
# If we cannot parse the previous event for some reason, simply treat it as a new event.
|
||||
|
|
|
@ -27,8 +27,8 @@ Take a look at the class ``BaseCollection`` if you want to implement your own.
|
|||
import json
|
||||
import xml.etree.ElementTree as ET
|
||||
from hashlib import sha256
|
||||
from typing import (Callable, ContextManager, Iterable, Iterator, Mapping,
|
||||
Optional, Sequence, Set, Tuple, Union, overload, Dict, List)
|
||||
from typing import (Callable, ContextManager, Dict, Iterable, Iterator, List,
|
||||
Mapping, Optional, Sequence, Set, Tuple, Union, overload)
|
||||
|
||||
import vobject
|
||||
|
||||
|
@ -43,7 +43,8 @@ INTERNAL_TYPES: Sequence[str] = ("multifilesystem", "multifilesystem_nolock",)
|
|||
# NOTE: change only if cache structure is modified to avoid cache invalidation on update
|
||||
CACHE_VERSION_RADICALE = "3.3.1"
|
||||
|
||||
CACHE_VERSION: bytes = ("%s=%s;%s=%s;" % ("radicale", CACHE_VERSION_RADICALE, "vobject", utils.package_version("vobject"))).encode()
|
||||
CACHE_VERSION: bytes = (
|
||||
"%s=%s;%s=%s;" % ("radicale", CACHE_VERSION_RADICALE, "vobject", utils.package_version("vobject"))).encode()
|
||||
|
||||
|
||||
def load(configuration: "config.Configuration") -> "BaseStorage":
|
||||
|
@ -111,17 +112,18 @@ class BaseCollection:
|
|||
invalid.
|
||||
|
||||
"""
|
||||
|
||||
def hrefs_iter() -> Iterator[str]:
|
||||
for item in self.get_all():
|
||||
assert item.href
|
||||
yield item.href
|
||||
|
||||
token = "http://radicale.org/ns/sync/%s" % self.etag.strip("\"")
|
||||
if old_token:
|
||||
raise ValueError("Sync token are not supported")
|
||||
return token, hrefs_iter()
|
||||
|
||||
def get_multi(self, hrefs: Iterable[str]
|
||||
) -> Iterable[Tuple[str, Optional["radicale_item.Item"]]]:
|
||||
def get_multi(self, hrefs: Iterable[str]) -> Iterable[Tuple[str, Optional["radicale_item.Item"]]]:
|
||||
"""Fetch multiple items.
|
||||
|
||||
It's not required to return the requested items in the correct order.
|
||||
|
@ -169,7 +171,7 @@ class BaseCollection:
|
|||
return False
|
||||
|
||||
def upload(self, href: str, item: "radicale_item.Item") -> (
|
||||
"radicale_item.Item", Optional["radicale_item.Item"]):
|
||||
Tuple)["radicale_item.Item", Optional["radicale_item.Item"]]:
|
||||
"""Upload a new or replace an existing item.
|
||||
|
||||
Return the uploaded item and the old item if it was replaced.
|
||||
|
@ -185,10 +187,12 @@ class BaseCollection:
|
|||
raise NotImplementedError
|
||||
|
||||
@overload
|
||||
def get_meta(self, key: None = None) -> Mapping[str, str]: ...
|
||||
def get_meta(self, key: None = None) -> Mapping[str, str]:
|
||||
...
|
||||
|
||||
@overload
|
||||
def get_meta(self, key: str) -> Optional[str]: ...
|
||||
def get_meta(self, key: str) -> Optional[str]:
|
||||
...
|
||||
|
||||
def get_meta(self, key: Optional[str] = None
|
||||
) -> Union[Mapping[str, str], Optional[str]]:
|
||||
|
@ -291,7 +295,7 @@ class BaseStorage:
|
|||
def discover(
|
||||
self, path: str, depth: str = "0",
|
||||
child_context_manager: Optional[
|
||||
Callable[[str, Optional[str]], ContextManager[None]]] = None,
|
||||
Callable[[str, Optional[str]], ContextManager[None]]] = None,
|
||||
user_groups: Set[str] = set([])) -> Iterable["types.CollectionOrItem"]:
|
||||
"""Discover a list of collections under the given ``path``.
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import os
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import Iterable, Optional, cast, List, Tuple, Dict
|
||||
from typing import Dict, Iterable, List, Optional, Tuple, cast
|
||||
|
||||
import radicale.item as radicale_item
|
||||
from radicale import pathutils
|
||||
|
|
|
@ -21,7 +21,7 @@ import errno
|
|||
import os
|
||||
import pickle
|
||||
import sys
|
||||
from typing import Iterable, Iterator, TextIO, cast, Optional, Tuple
|
||||
from typing import Iterable, Iterator, Optional, TextIO, Tuple, cast
|
||||
|
||||
import radicale.item as radicale_item
|
||||
from radicale import pathutils
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue