From c61cbdf3c1b749f18f3b17feb06bdba3e0812869 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Sat, 19 Jul 2025 23:38:37 -0600 Subject: [PATCH] - Linting --- radicale/app/put.py | 2 +- radicale/config.py | 2 +- radicale/hook/email/__init__.py | 5 +++-- radicale/storage/__init__.py | 22 +++++++++++-------- .../multifilesystem/create_collection.py | 2 +- radicale/storage/multifilesystem/upload.py | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/radicale/app/put.py b/radicale/app/put.py index a38499ef..a582b34d 100644 --- a/radicale/app/put.py +++ b/radicale/app/put.py @@ -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, diff --git a/radicale/config.py b/radicale/config.py index 7a059b71..ed592a48 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -503,7 +503,7 @@ The following event has been updated. $event_title $event_start_time - $event_end_time $event_location - + This is an automated message. Please do not reply.""", "help": "Template for the email sent when an event is updated. Select placeholder words prefixed with $ will be replaced", "type": str diff --git a/radicale/hook/email/__init__.py b/radicale/hook/email/__init__.py index 034882ee..22e31420 100644 --- a/radicale/hook/email/__init__.py +++ b/radicale/hook/email/__init__.py @@ -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. diff --git a/radicale/storage/__init__.py b/radicale/storage/__init__.py index 1e6157e4..6cbf3f5a 100644 --- a/radicale/storage/__init__.py +++ b/radicale/storage/__init__.py @@ -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``. diff --git a/radicale/storage/multifilesystem/create_collection.py b/radicale/storage/multifilesystem/create_collection.py index 6bbb4062..71aca377 100644 --- a/radicale/storage/multifilesystem/create_collection.py +++ b/radicale/storage/multifilesystem/create_collection.py @@ -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 diff --git a/radicale/storage/multifilesystem/upload.py b/radicale/storage/multifilesystem/upload.py index 6f163e8b..674477c7 100644 --- a/radicale/storage/multifilesystem/upload.py +++ b/radicale/storage/multifilesystem/upload.py @@ -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