diff --git a/requirements/common.txt b/requirements/common.txt index 895506feab..58413f1e54 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -1,6 +1,9 @@ # Django itself; we use a slightly patched version Django==1.11.4 +# needed for mypy TypedDict +mypy_extensions==0.3.0 + # Needed for rendering backend templates Jinja2==2.9.6 diff --git a/requirements/dev_lock.txt b/requirements/dev_lock.txt index 131f480149..b5445807d6 100644 --- a/requirements/dev_lock.txt +++ b/requirements/dev_lock.txt @@ -76,6 +76,7 @@ markdown==2.6.9 # via markdown-include markupsafe==1.0 mock==2.0.0 moto==1.0.1 +mypy_extensions==0.3.0 ndg-httpsclient==0.4.2 oauth2client==4.1.2 oauthlib==2.0.2 diff --git a/requirements/prod_lock.txt b/requirements/prod_lock.txt index da44d33280..9af5867230 100644 --- a/requirements/prod_lock.txt +++ b/requirements/prod_lock.txt @@ -52,6 +52,7 @@ markdown-include==0.5.1 markdown==2.6.9 # via markdown-include markupsafe==1.0 mock==2.0.0 +mypy_extensions==0.3.0 ndg-httpsclient==0.4.2 oauth2client==4.1.2 oauthlib==2.0.2 diff --git a/version.py b/version.py index 6c705f273a..2fc326ea60 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ ZULIP_VERSION = "1.6.0+git" -PROVISION_VERSION = '9.5' +PROVISION_VERSION = '9.6' diff --git a/zerver/lib/message.py b/zerver/lib/message.py index eab93197a6..6e46453966 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -29,9 +29,18 @@ from zerver.models import ( ) from typing import Any, Dict, List, Optional, Set, Tuple, Text, Union +from mypy_extensions import TypedDict RealmAlertWords = Dict[int, List[Text]] +UnreadMessagesResult = TypedDict('UnreadMessagesResult', { + 'pms': List[Dict[str, Any]], + 'streams': List[Dict[str, Any]], + 'huddles': List[Dict[str, Any]], + 'mentions': List[int], + 'count': int, +}) + MAX_UNREAD_MESSAGES = 5000 def extract_message_dict(message_bytes): @@ -413,7 +422,7 @@ def get_muted_recipient_ids(user_profile): return muted_recipient_ids def get_unread_message_ids_per_recipient(user_profile): - # type: (UserProfile) -> Dict[str, Any] + # type: (UserProfile) -> UnreadMessagesResult excluded_recipient_ids = get_inactive_recipient_ids(user_profile) @@ -510,8 +519,7 @@ def get_unread_message_ids_per_recipient(user_profile): streams=stream_objects, huddles=huddle_objects, mentions=mentioned_message_ids, - count=count, - ) + count=count) # type: UnreadMessagesResult return result