mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-26 13:15:19 -04:00
Add some type hints to datastore (#12485)
This commit is contained in:
parent
63ba9ba38b
commit
b76f1a4d5f
12 changed files with 188 additions and 84 deletions
|
@ -15,11 +15,12 @@
|
|||
|
||||
import itertools
|
||||
import logging
|
||||
from typing import Dict, Iterable, List, Optional, Tuple
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
from signedjson.key import decode_verify_key_bytes
|
||||
|
||||
from synapse.storage._base import SQLBaseStore
|
||||
from synapse.storage.database import LoggingTransaction
|
||||
from synapse.storage.keys import FetchKeyResult
|
||||
from synapse.storage.types import Cursor
|
||||
from synapse.util.caches.descriptors import cached, cachedList
|
||||
|
@ -35,7 +36,9 @@ class KeyStore(SQLBaseStore):
|
|||
"""Persistence for signature verification keys"""
|
||||
|
||||
@cached()
|
||||
def _get_server_verify_key(self, server_name_and_key_id):
|
||||
def _get_server_verify_key(
|
||||
self, server_name_and_key_id: Tuple[str, str]
|
||||
) -> FetchKeyResult:
|
||||
raise NotImplementedError()
|
||||
|
||||
@cachedList(
|
||||
|
@ -179,19 +182,21 @@ class KeyStore(SQLBaseStore):
|
|||
|
||||
async def get_server_keys_json(
|
||||
self, server_keys: Iterable[Tuple[str, Optional[str], Optional[str]]]
|
||||
) -> Dict[Tuple[str, Optional[str], Optional[str]], List[dict]]:
|
||||
) -> Dict[Tuple[str, Optional[str], Optional[str]], List[Dict[str, Any]]]:
|
||||
"""Retrieve the key json for a list of server_keys and key ids.
|
||||
If no keys are found for a given server, key_id and source then
|
||||
that server, key_id, and source triplet entry will be an empty list.
|
||||
The JSON is returned as a byte array so that it can be efficiently
|
||||
used in an HTTP response.
|
||||
Args:
|
||||
server_keys (list): List of (server_name, key_id, source) triplets.
|
||||
server_keys: List of (server_name, key_id, source) triplets.
|
||||
Returns:
|
||||
A mapping from (server_name, key_id, source) triplets to a list of dicts
|
||||
"""
|
||||
|
||||
def _get_server_keys_json_txn(txn):
|
||||
def _get_server_keys_json_txn(
|
||||
txn: LoggingTransaction,
|
||||
) -> Dict[Tuple[str, Optional[str], Optional[str]], List[Dict[str, Any]]]:
|
||||
results = {}
|
||||
for server_name, key_id, from_server in server_keys:
|
||||
keyvalues = {"server_name": server_name}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue