summary refs log tree commit diff
path: root/synapse/types.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-03-18 13:51:41 +0000
committerGitHub <noreply@github.com>2022-03-18 13:51:41 +0000
commit872dbb0181714e201be082c4e8bd9b727c73f177 (patch)
tree2d70f1c88fb93d2d52668dd846afd5c9395a30c3 /synapse/types.py
parentGenerate announcement links in release script (#12242) (diff)
downloadsynapse-872dbb0181714e201be082c4e8bd9b727c73f177.tar.xz
Correct `check_username_for_spam` annotations and docs (#12246)
* Formally type the UserProfile in user searches
* export UserProfile in synapse.module_api
* Update docs

Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Diffstat (limited to 'synapse/types.py')
-rw-r--r--synapse/types.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/types.py b/synapse/types.py
index 53be3583a0..5ce2a5b0a5 100644
--- a/synapse/types.py
+++ b/synapse/types.py
@@ -34,6 +34,7 @@ from typing import (
 import attr
 from frozendict import frozendict
 from signedjson.key import decode_verify_key_bytes
+from typing_extensions import TypedDict
 from unpaddedbase64 import decode_base64
 from zope.interface import Interface
 
@@ -63,6 +64,10 @@ MutableStateMap = MutableMapping[StateKey, T]
 # JSON types. These could be made stronger, but will do for now.
 # A JSON-serialisable dict.
 JsonDict = Dict[str, Any]
+# A JSON-serialisable mapping; roughly speaking an immutable JSONDict.
+# Useful when you have a TypedDict which isn't going to be mutated and you don't want
+# to cast to JsonDict everywhere.
+JsonMapping = Mapping[str, Any]
 # A JSON-serialisable object.
 JsonSerializable = object
 
@@ -791,3 +796,9 @@ class UserInfo:
     is_deactivated: bool
     is_guest: bool
     is_shadow_banned: bool
+
+
+class UserProfile(TypedDict):
+    user_id: str
+    display_name: Optional[str]
+    avatar_url: Optional[str]