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

Commit a78016d

Browse files
authored
Add type hints to E2E handler. (#9232)
This finishes adding type hints to the `synapse.handlers` module.
1 parent 34efb4c commit a78016d

File tree

7 files changed

+198
-177
lines changed

7 files changed

+198
-177
lines changed

changelog.d/9232.misc

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

mypy.ini

+1-41
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,7 @@ files =
2323
synapse/events/validator.py,
2424
synapse/events/spamcheck.py,
2525
synapse/federation,
26-
synapse/handlers/_base.py,
27-
synapse/handlers/account_data.py,
28-
synapse/handlers/account_validity.py,
29-
synapse/handlers/acme.py,
30-
synapse/handlers/acme_issuing_service.py,
31-
synapse/handlers/admin.py,
32-
synapse/handlers/appservice.py,
33-
synapse/handlers/auth.py,
34-
synapse/handlers/cas_handler.py,
35-
synapse/handlers/deactivate_account.py,
36-
synapse/handlers/device.py,
37-
synapse/handlers/devicemessage.py,
38-
synapse/handlers/directory.py,
39-
synapse/handlers/events.py,
40-
synapse/handlers/federation.py,
41-
synapse/handlers/groups_local.py,
42-
synapse/handlers/identity.py,
43-
synapse/handlers/initial_sync.py,
44-
synapse/handlers/message.py,
45-
synapse/handlers/oidc_handler.py,
46-
synapse/handlers/pagination.py,
47-
synapse/handlers/password_policy.py,
48-
synapse/handlers/presence.py,
49-
synapse/handlers/profile.py,
50-
synapse/handlers/read_marker.py,
51-
synapse/handlers/receipts.py,
52-
synapse/handlers/register.py,
53-
synapse/handlers/room.py,
54-
synapse/handlers/room_list.py,
55-
synapse/handlers/room_member.py,
56-
synapse/handlers/room_member_worker.py,
57-
synapse/handlers/saml_handler.py,
58-
synapse/handlers/search.py,
59-
synapse/handlers/set_password.py,
60-
synapse/handlers/sso.py,
61-
synapse/handlers/state_deltas.py,
62-
synapse/handlers/stats.py,
63-
synapse/handlers/sync.py,
64-
synapse/handlers/typing.py,
65-
synapse/handlers/user_directory.py,
66-
synapse/handlers/ui_auth,
26+
synapse/handlers,
6727
synapse/http/client.py,
6828
synapse/http/federation/matrix_federation_agent.py,
6929
synapse/http/federation/well_known_resolver.py,

synapse/handlers/device.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
import logging
18-
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple
18+
from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Set, Tuple
1919

2020
from synapse.api import errors
2121
from synapse.api.constants import EventTypes
@@ -62,7 +62,7 @@ def __init__(self, hs: "HomeServer"):
6262
self._auth_handler = hs.get_auth_handler()
6363

6464
@trace
65-
async def get_devices_by_user(self, user_id: str) -> List[Dict[str, Any]]:
65+
async def get_devices_by_user(self, user_id: str) -> List[JsonDict]:
6666
"""
6767
Retrieve the given user's devices
6868
@@ -85,7 +85,7 @@ async def get_devices_by_user(self, user_id: str) -> List[Dict[str, Any]]:
8585
return devices
8686

8787
@trace
88-
async def get_device(self, user_id: str, device_id: str) -> Dict[str, Any]:
88+
async def get_device(self, user_id: str, device_id: str) -> JsonDict:
8989
""" Retrieve the given device
9090
9191
Args:
@@ -598,7 +598,7 @@ async def rehydrate_device(
598598

599599

600600
def _update_device_from_client_ips(
601-
device: Dict[str, Any], client_ips: Dict[Tuple[str, str], Dict[str, Any]]
601+
device: JsonDict, client_ips: Dict[Tuple[str, str], JsonDict]
602602
) -> None:
603603
ip = client_ips.get((device["user_id"], device["device_id"]), {})
604604
device.update({"last_seen_ts": ip.get("last_seen"), "last_seen_ip": ip.get("ip")})
@@ -946,8 +946,8 @@ async def user_device_resync(
946946
async def process_cross_signing_key_update(
947947
self,
948948
user_id: str,
949-
master_key: Optional[Dict[str, Any]],
950-
self_signing_key: Optional[Dict[str, Any]],
949+
master_key: Optional[JsonDict],
950+
self_signing_key: Optional[JsonDict],
951951
) -> List[str]:
952952
"""Process the given new master and self-signing key for the given remote user.
953953

0 commit comments

Comments
 (0)