From a5cf912ae89e71af9cbb8e1d3257c6fc131ef9f1 Mon Sep 17 00:00:00 2001 From: Joeri de Ruiter Date: Wed, 13 Sep 2023 09:22:53 +0200 Subject: [PATCH] Fix some annotations --- bookwyrm/activitypub/base_activity.py | 5 ++++- bookwyrm/utils/cache.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index f7f4b216c..05e7d8a05 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -1,4 +1,5 @@ """ basics for an activitypub serializer """ +from __future__ import annotations from dataclasses import dataclass, fields, MISSING from json import JSONEncoder import logging @@ -72,7 +73,9 @@ class ActivityObject: def __init__( self, - activity_objects: Optional[list[str, base_model.BookWyrmModel]] = None, + activity_objects: Optional[ + dict[str, Union[str, list[str], ActivityObject, base_model.BookWyrmModel]] + ] = None, **kwargs: Any, ): """this lets you pass in an object with fields that aren't in the diff --git a/bookwyrm/utils/cache.py b/bookwyrm/utils/cache.py index 5e896e621..c8262ef59 100644 --- a/bookwyrm/utils/cache.py +++ b/bookwyrm/utils/cache.py @@ -6,12 +6,12 @@ from django.core.cache import cache def get_or_set( cache_key: str, - function: Callable[..., Any], + function: Callable[..., str], *args: Tuple[Any, ...], timeout: Union[float, None] = None -) -> Any: +) -> str: """Django's built-in get_or_set isn't cutting it""" - value = cache.get(cache_key) + value = str(cache.get(cache_key)) if value is None: value = function(*args) cache.set(cache_key, value, timeout=timeout)