|
4 | 4 | from concurrent.futures import Future, ThreadPoolExecutor, wait
|
5 | 5 | from typing import (
|
6 | 6 | Any, Callable, DefaultDict, Dict, FrozenSet, Iterable, List, Optional, Set,
|
7 |
| - Tuple, Union, |
| 7 | + Tuple, Union, cast, |
8 | 8 | )
|
9 | 9 | from urllib.parse import urlparse
|
10 | 10 |
|
|
14 | 14 | from zulipterminal import unicode_emojis
|
15 | 15 | from zulipterminal.config.keys import keys_for_command
|
16 | 16 | from zulipterminal.helper import (
|
17 |
| - Message, asynch, canonicalize_color, classify_unread_counts, |
18 |
| - display_error_if_present, index_messages, initial_index, notify, set_count, |
| 17 | + Message, NamedEmojiData, asynch, canonicalize_color, |
| 18 | + classify_unread_counts, display_error_if_present, index_messages, |
| 19 | + initial_index, notify, set_count, |
19 | 20 | )
|
20 | 21 | from zulipterminal.ui_tools.utils import create_msg_box_list
|
21 | 22 |
|
@@ -139,9 +140,10 @@ def __init__(self, controller: Any) -> None:
|
139 | 140 | unicode_emoji_data = unicode_emojis.EMOJI_DATA
|
140 | 141 | for name, data in unicode_emoji_data.items():
|
141 | 142 | data['type'] = 'unicode_emoji'
|
| 143 | + typed_unicode_emoji_data = cast(NamedEmojiData, unicode_emoji_data) |
142 | 144 |
|
143 | 145 | custom_emojis = self.fetch_custom_emojis()
|
144 |
| - all_emojis = (list(unicode_emoji_data.items()) |
| 146 | + all_emojis = (list(typed_unicode_emoji_data.items()) |
145 | 147 | + list(custom_emojis.items()))
|
146 | 148 | self.active_emoji_data = OrderedDict(sorted(all_emojis,
|
147 | 149 | key=lambda e: e[0]))
|
@@ -364,12 +366,12 @@ def update_stream_message(self, topic: str, message_id: int,
|
364 | 366 | display_error_if_present(response, self.controller)
|
365 | 367 | return response['result'] == 'success'
|
366 | 368 |
|
367 |
| - def fetch_custom_emojis(self) -> Dict[str, Dict[str, str]]: |
| 369 | + def fetch_custom_emojis(self) -> NamedEmojiData: |
368 | 370 | response = self.client.get_realm_emoji()
|
369 | 371 | custom_emojis = {emoji['name']: {'code': emoji_code,
|
370 | 372 | 'type': 'realm_emoji'}
|
371 | 373 | for emoji_code, emoji in response['emoji'].items()
|
372 |
| - if not emoji['deactivated']} |
| 374 | + if not emoji['deactivated']} # type: NamedEmojiData |
373 | 375 | return custom_emojis
|
374 | 376 |
|
375 | 377 | def get_messages(self, *,
|
|
0 commit comments