mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-06-03 05:49:35 +00:00
Fix some annotations
This commit is contained in:
parent
a5ede835b2
commit
a5cf912ae8
|
@ -1,4 +1,5 @@
|
||||||
""" basics for an activitypub serializer """
|
""" basics for an activitypub serializer """
|
||||||
|
from __future__ import annotations
|
||||||
from dataclasses import dataclass, fields, MISSING
|
from dataclasses import dataclass, fields, MISSING
|
||||||
from json import JSONEncoder
|
from json import JSONEncoder
|
||||||
import logging
|
import logging
|
||||||
|
@ -72,7 +73,9 @@ class ActivityObject:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
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,
|
**kwargs: Any,
|
||||||
):
|
):
|
||||||
"""this lets you pass in an object with fields that aren't in the
|
"""this lets you pass in an object with fields that aren't in the
|
||||||
|
|
|
@ -6,12 +6,12 @@ from django.core.cache import cache
|
||||||
|
|
||||||
def get_or_set(
|
def get_or_set(
|
||||||
cache_key: str,
|
cache_key: str,
|
||||||
function: Callable[..., Any],
|
function: Callable[..., str],
|
||||||
*args: Tuple[Any, ...],
|
*args: Tuple[Any, ...],
|
||||||
timeout: Union[float, None] = None
|
timeout: Union[float, None] = None
|
||||||
) -> Any:
|
) -> str:
|
||||||
"""Django's built-in get_or_set isn't cutting it"""
|
"""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:
|
if value is None:
|
||||||
value = function(*args)
|
value = function(*args)
|
||||||
cache.set(cache_key, value, timeout=timeout)
|
cache.set(cache_key, value, timeout=timeout)
|
||||||
|
|
Loading…
Reference in a new issue