mypy: Use TypedDict for UnreadMessageResult.

This commit is contained in:
Steve Howell
2017-08-08 22:01:00 -04:00
committed by Tim Abbott
parent 0519bade1b
commit 0106add546
5 changed files with 17 additions and 4 deletions

View File

@@ -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