diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 3c0be51ae0..9a7dd7c7ff 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -1,7 +1,7 @@ # See https://zulip.readthedocs.io/en/latest/subsystems/events-system.html for # high-level documentation on how this system works. from typing import cast, AbstractSet, Any, Callable, Dict, List, \ - Mapping, MutableMapping, Optional, Iterable, Sequence, Set, Text, Union + Mapping, MutableMapping, Optional, Iterable, Sequence, Set, Union from mypy_extensions import TypedDict from django.utils.translation import ugettext as _ @@ -59,10 +59,10 @@ HEARTBEAT_MIN_FREQ_SECS = 45 class ClientDescriptor: def __init__(self, user_profile_id: int, - user_profile_email: Text, + user_profile_email: str, realm_id: int, event_queue: 'EventQueue', event_types: Optional[Sequence[str]], - client_type_name: Text, + client_type_name: str, apply_markdown: bool=True, client_gravatar: bool=True, all_public_streams: bool=False, @@ -76,7 +76,7 @@ class ClientDescriptor: self.user_profile_email = user_profile_email self.realm_id = realm_id self.current_handler_id = None # type: Optional[int] - self.current_client_name = None # type: Optional[Text] + self.current_client_name = None # type: Optional[str] self.event_queue = event_queue self.queue_timeout = lifespan_secs self.event_types = event_types @@ -185,7 +185,7 @@ class ClientDescriptor: return (self.current_handler_id is None and now - self.last_connection_time >= self.queue_timeout) - def connect_handler(self, handler_id: int, client_name: Text) -> None: + def connect_handler(self, handler_id: int, client_name: str) -> None: self.current_handler_id = handler_id self.current_client_name = client_name set_descriptor_by_handler_id(handler_id, self) @@ -488,8 +488,8 @@ def fetch_events(query: Mapping[str, Any]) -> Dict[str, Any]: last_event_id = query["last_event_id"] # type: int user_profile_id = query["user_profile_id"] # type: int new_queue_data = query.get("new_queue_data") # type: Optional[MutableMapping[str, Any]] - user_profile_email = query["user_profile_email"] # type: Text - client_type_name = query["client_type_name"] # type: Text + user_profile_email = query["user_profile_email"] # type: str + client_type_name = query["client_type_name"] # type: str handler_id = query["handler_id"] # type: int try: @@ -553,7 +553,7 @@ def request_event_queue(user_profile: UserProfile, user_client: Client, apply_ma client_gravatar: bool, queue_lifespan_secs: int, event_types: Optional[Iterable[str]]=None, all_public_streams: bool=False, - narrow: Iterable[Sequence[Text]]=[]) -> Optional[str]: + narrow: Iterable[Sequence[str]]=[]) -> Optional[str]: if settings.TORNADO_SERVER: req = {'dont_block': 'true', 'apply_markdown': ujson.dumps(apply_markdown), @@ -767,7 +767,7 @@ def process_message_event(event_template: Mapping[str, Any], users: Iterable[Map sender_id = wide_dict['sender_id'] # type: int message_id = wide_dict['id'] # type: int message_type = wide_dict['type'] # type: str - sending_client = wide_dict['client'] # type: Text + sending_client = wide_dict['client'] # type: str @cachify def get_client_payload(apply_markdown: bool, client_gravatar: bool) -> Dict[str, Any]: diff --git a/zerver/tornado/socket.py b/zerver/tornado/socket.py index 8a29aa9f95..810f9dd575 100644 --- a/zerver/tornado/socket.py +++ b/zerver/tornado/socket.py @@ -1,5 +1,5 @@ -from typing import Any, Dict, Mapping, Optional, Text, Union +from typing import Any, Dict, Mapping, Optional, Union from django.conf import settings from django.utils.timezone import now as timezone_now @@ -32,7 +32,7 @@ from zerver.tornado.exceptions import BadEventQueueIdError logger = logging.getLogger('zulip.socket') -def get_user_profile(session_id: Optional[Text]) -> Optional[UserProfile]: +def get_user_profile(session_id: Optional[str]) -> Optional[UserProfile]: if session_id is None: return None @@ -66,7 +66,7 @@ def deregister_connection(conn: 'SocketConnection') -> None: redis_client = get_redis_client() -def req_redis_key(req_id: Text) -> Text: +def req_redis_key(req_id: str) -> str: return 'socket_req_status:%s' % (req_id,) class CloseErrorInfo: diff --git a/zerver/tornado/views.py b/zerver/tornado/views.py index 44e79d983b..0fdef5d34e 100644 --- a/zerver/tornado/views.py +++ b/zerver/tornado/views.py @@ -1,6 +1,6 @@ import time -from typing import Iterable, List, Optional, Sequence, Text, Union +from typing import Iterable, List, Optional, Sequence, Union import ujson from django.core.handlers.base import BaseHandler @@ -24,7 +24,7 @@ def notify(request: HttpRequest) -> HttpResponse: @has_request_variables def cleanup_event_queue(request: HttpRequest, user_profile: UserProfile, - queue_id: Text=REQ()) -> HttpResponse: + queue_id: str=REQ()) -> HttpResponse: client = get_client_descriptor(str(queue_id)) if client is None: raise BadEventQueueIdError(queue_id) @@ -39,13 +39,13 @@ def cleanup_event_queue(request: HttpRequest, user_profile: UserProfile, def get_events_backend(request: HttpRequest, user_profile: UserProfile, handler: BaseHandler, user_client: Optional[Client]=REQ(converter=get_client, default=None), last_event_id: Optional[int]=REQ(converter=int, default=None), - queue_id: Optional[List[Text]]=REQ(default=None), + queue_id: Optional[List[str]]=REQ(default=None), apply_markdown: bool=REQ(default=False, validator=check_bool), client_gravatar: bool=REQ(default=False, validator=check_bool), all_public_streams: bool=REQ(default=False, validator=check_bool), - event_types: Optional[Text]=REQ(default=None, validator=check_list(check_string)), + event_types: Optional[str]=REQ(default=None, validator=check_list(check_string)), dont_block: bool=REQ(default=False, validator=check_bool), - narrow: Iterable[Sequence[Text]]=REQ(default=[], validator=check_list(None)), + narrow: Iterable[Sequence[str]]=REQ(default=[], validator=check_list(None)), lifespan_secs: int=REQ(default=0, converter=int) ) -> Union[HttpResponse, _RespondAsynchronously]: if user_client is None: