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)
|
props=props)
|
||||||
for item in prepared_items:
|
for item in prepared_items:
|
||||||
# Try to grab the previously-existing item by href
|
# 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:
|
if existing_item:
|
||||||
hook_notification_item = HookNotificationItem(
|
hook_notification_item = HookNotificationItem(
|
||||||
notification_item_type=HookNotificationItemTypes.UPSERT,
|
notification_item_type=HookNotificationItemTypes.UPSERT,
|
||||||
|
|
|
@ -17,7 +17,8 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
import vobject
|
import vobject
|
||||||
|
|
||||||
from radicale.hook import (BaseHook, HookNotificationItem, HookNotificationItemTypes)
|
from radicale.hook import (BaseHook, HookNotificationItem,
|
||||||
|
HookNotificationItemTypes)
|
||||||
from radicale.log import logger
|
from radicale.log import logger
|
||||||
|
|
||||||
PLUGIN_CONFIG_SCHEMA = {
|
PLUGIN_CONFIG_SCHEMA = {
|
||||||
|
@ -962,7 +963,7 @@ class Hook(BaseHook):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Dealing with an update to an existing event, compare new and previous content.
|
# 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)
|
previous_event: Optional[Event] = read_ics_event(contents=previous_item_str)
|
||||||
if not previous_event:
|
if not previous_event:
|
||||||
# If we cannot parse the previous event for some reason, simply treat it as a new 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 json
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from typing import (Callable, ContextManager, Iterable, Iterator, Mapping,
|
from typing import (Callable, ContextManager, Dict, Iterable, Iterator, List,
|
||||||
Optional, Sequence, Set, Tuple, Union, overload, Dict, List)
|
Mapping, Optional, Sequence, Set, Tuple, Union, overload)
|
||||||
|
|
||||||
import vobject
|
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
|
# NOTE: change only if cache structure is modified to avoid cache invalidation on update
|
||||||
CACHE_VERSION_RADICALE = "3.3.1"
|
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":
|
def load(configuration: "config.Configuration") -> "BaseStorage":
|
||||||
|
@ -111,17 +112,18 @@ class BaseCollection:
|
||||||
invalid.
|
invalid.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def hrefs_iter() -> Iterator[str]:
|
def hrefs_iter() -> Iterator[str]:
|
||||||
for item in self.get_all():
|
for item in self.get_all():
|
||||||
assert item.href
|
assert item.href
|
||||||
yield item.href
|
yield item.href
|
||||||
|
|
||||||
token = "http://radicale.org/ns/sync/%s" % self.etag.strip("\"")
|
token = "http://radicale.org/ns/sync/%s" % self.etag.strip("\"")
|
||||||
if old_token:
|
if old_token:
|
||||||
raise ValueError("Sync token are not supported")
|
raise ValueError("Sync token are not supported")
|
||||||
return token, hrefs_iter()
|
return token, hrefs_iter()
|
||||||
|
|
||||||
def get_multi(self, hrefs: Iterable[str]
|
def get_multi(self, hrefs: Iterable[str]) -> Iterable[Tuple[str, Optional["radicale_item.Item"]]]:
|
||||||
) -> Iterable[Tuple[str, Optional["radicale_item.Item"]]]:
|
|
||||||
"""Fetch multiple items.
|
"""Fetch multiple items.
|
||||||
|
|
||||||
It's not required to return the requested items in the correct order.
|
It's not required to return the requested items in the correct order.
|
||||||
|
@ -169,7 +171,7 @@ class BaseCollection:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def upload(self, href: str, item: "radicale_item.Item") -> (
|
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.
|
"""Upload a new or replace an existing item.
|
||||||
|
|
||||||
Return the uploaded item and the old item if it was replaced.
|
Return the uploaded item and the old item if it was replaced.
|
||||||
|
@ -185,10 +187,12 @@ class BaseCollection:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def get_meta(self, key: None = None) -> Mapping[str, str]: ...
|
def get_meta(self, key: None = None) -> Mapping[str, str]:
|
||||||
|
...
|
||||||
|
|
||||||
@overload
|
@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
|
def get_meta(self, key: Optional[str] = None
|
||||||
) -> Union[Mapping[str, str], Optional[str]]:
|
) -> Union[Mapping[str, str], Optional[str]]:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from tempfile import TemporaryDirectory
|
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
|
import radicale.item as radicale_item
|
||||||
from radicale import pathutils
|
from radicale import pathutils
|
||||||
|
|
|
@ -21,7 +21,7 @@ import errno
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import sys
|
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
|
import radicale.item as radicale_item
|
||||||
from radicale import pathutils
|
from radicale import pathutils
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue