Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Improve type annotation on CachedListDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Feb 28, 2022
1 parent 880aa99 commit fd103e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions synapse/util/caches/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
from typing import (
Any,
Awaitable,
Callable,
Dict,
Generic,
Expand Down Expand Up @@ -354,7 +355,7 @@ class DeferredCacheListDescriptor(_CacheDescriptorBase):

def __init__(
self,
orig: Callable[..., Any],
orig: Callable[..., Awaitable[Dict]],
cached_method_name: str,
list_name: str,
num_args: Optional[int] = None,
Expand Down Expand Up @@ -385,13 +386,13 @@ def __init__(

def __get__(
self, obj: Optional[Any], objtype: Optional[Type] = None
) -> Callable[..., Any]:
) -> Callable[..., "defer.Deferred[Dict[Hashable, Any]]"]:
cached_method = getattr(obj, self.cached_method_name)
cache: DeferredCache[CacheKey, Any] = cached_method.cache
num_args = cached_method.num_args

@functools.wraps(self.orig)
def wrapped(*args: Any, **kwargs: Any) -> Any:
def wrapped(*args: Any, **kwargs: Any) -> "defer.Deferred[Dict]":
# If we're passed a cache_context then we'll want to call its
# invalidate() whenever we are invalidated
invalidate_callback = kwargs.pop("on_invalidate", None)
Expand Down

0 comments on commit fd103e6

Please sign in to comment.