Fix some annotations

This commit is contained in:
Joeri de Ruiter 2023-09-13 09:22:53 +02:00
parent a5ede835b2
commit a5cf912ae8
2 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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)