diff options
author | David Robertson <davidr@element.io> | 2023-09-08 19:29:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 19:29:38 +0100 |
commit | edd83f23b710f0caae05d5766b474de3b6f24e9e (patch) | |
tree | 91c841f77e186fea9ede52df87d50126541162d1 /synapse/util/caches/dictionary_cache.py | |
parent | Upgrade CI run of Python 3.12 from rc1 to rc2 (#16280) (diff) | |
download | synapse-edd83f23b710f0caae05d5766b474de3b6f24e9e.tar.xz |
Improve type hints for attrs classes (#16276)
Diffstat (limited to 'synapse/util/caches/dictionary_cache.py')
-rw-r--r-- | synapse/util/caches/dictionary_cache.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/synapse/util/caches/dictionary_cache.py b/synapse/util/caches/dictionary_cache.py index 5eaf70c7ab..2fbc7b1e6c 100644 --- a/synapse/util/caches/dictionary_cache.py +++ b/synapse/util/caches/dictionary_cache.py @@ -14,7 +14,7 @@ import enum import logging import threading -from typing import Any, Dict, Generic, Iterable, Optional, Set, Tuple, TypeVar, Union +from typing import Dict, Generic, Iterable, Optional, Set, Tuple, TypeVar, Union import attr from typing_extensions import Literal @@ -33,10 +33,8 @@ DKT = TypeVar("DKT") DV = TypeVar("DV") -# This class can't be generic because it uses slots with attrs. -# See: https://github.com/python-attrs/attrs/issues/313 @attr.s(slots=True, frozen=True, auto_attribs=True) -class DictionaryEntry: # should be: Generic[DKT, DV]. +class DictionaryEntry(Generic[DKT, DV]): """Returned when getting an entry from the cache If `full` is true then `known_absent` will be the empty set. @@ -50,8 +48,8 @@ class DictionaryEntry: # should be: Generic[DKT, DV]. """ full: bool - known_absent: Set[Any] # should be: Set[DKT] - value: Dict[Any, Any] # should be: Dict[DKT, DV] + known_absent: Set[DKT] + value: Dict[DKT, DV] def __len__(self) -> int: return len(self.value) |