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

Commit 6a605f4

Browse files
author
David Robertson
authored
Get db signatures file to pass mypy (#11312)
1 parent 8dc666f commit 6a605f4

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

changelog.d/11312.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add type hints to storage classes.

mypy.ini

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ exclude = (?x)
4848
|synapse/storage/databases/main/room.py
4949
|synapse/storage/databases/main/roommember.py
5050
|synapse/storage/databases/main/search.py
51-
|synapse/storage/databases/main/signatures.py
5251
|synapse/storage/databases/main/state.py
5352
|synapse/storage/databases/main/state_deltas.py
5453
|synapse/storage/databases/main/stats.py

synapse/events/builder.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,12 @@ async def build(
128128
)
129129

130130
format_version = self.room_version.event_format
131+
# The types of auth/prev events changes between event versions.
132+
prev_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
133+
auth_events: Union[List[str], List[Tuple[str, Dict[str, str]]]]
131134
if format_version == EventFormatVersions.V1:
132-
# The types of auth/prev events changes between event versions.
133-
auth_events: Union[
134-
List[str], List[Tuple[str, Dict[str, str]]]
135-
] = await self._store.add_event_hashes(auth_event_ids)
136-
prev_events: Union[
137-
List[str], List[Tuple[str, Dict[str, str]]]
138-
] = await self._store.add_event_hashes(prev_event_ids)
135+
auth_events = await self._store.add_event_hashes(auth_event_ids)
136+
prev_events = await self._store.add_event_hashes(prev_event_ids)
139137
else:
140138
auth_events = auth_event_ids
141139
prev_events = prev_event_ids

synapse/storage/databases/main/signatures.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ async def add_event_hashes(
6363
A list of tuples of event ID and a mapping of algorithm to base-64 encoded hash.
6464
"""
6565
hashes = await self.get_event_reference_hashes(event_ids)
66-
hashes = {
66+
encoded_hashes = {
6767
e_id: {k: encode_base64(v) for k, v in h.items() if k == "sha256"}
6868
for e_id, h in hashes.items()
6969
}
7070

71-
return list(hashes.items())
71+
return list(encoded_hashes.items())
7272

7373
def _get_event_reference_hashes_txn(
7474
self, txn: Cursor, event_id: str

0 commit comments

Comments
 (0)