typing: Convert function type annotations to Python 3 style.

Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and two fixes for use-before-define
issues:

-    def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None:
+    def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None:

-def init_from_options(options: Any, client: Optional[str] = None) -> Client:
+def init_from_options(options: Any, client: Optional[str] = None) -> 'Client':

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-04-18 15:59:12 -07:00 committed by Tim Abbott
parent 7c5f73dce9
commit 5428c5f296
42 changed files with 311 additions and 577 deletions

View file

@ -53,13 +53,11 @@ class StubBotHandler:
def update_message(self, message: Dict[str, Any]) -> None:
self.message_server.update(message)
def upload_file_from_path(self, file_path):
# type: (str) -> Dict[str, Any]
def upload_file_from_path(self, file_path: str) -> Dict[str, Any]:
with open(file_path, 'rb') as file:
return self.message_server.upload_file(file)
def upload_file(self, file):
# type: (IO[Any]) -> Dict[str, Any]
def upload_file(self, file: IO[Any]) -> Dict[str, Any]:
return self.message_server.upload_file(file)
class BotQuitException(Exception):
@ -132,8 +130,7 @@ class BotTestCase(unittest.TestCase):
return bot, bot_handler
def get_response(self, message):
# type: (Dict[str, Any]) -> Dict[str, Any]
def get_response(self, message: Dict[str, Any]) -> Dict[str, Any]:
bot, bot_handler = self._get_handlers()
bot_handler.reset_transcript()
bot.handle_message(message, bot_handler)