From 9d5fbc2b5b46aa1b34b49973b2431d1a035c8e96 Mon Sep 17 00:00:00 2001 From: fredfishgames Date: Thu, 7 Dec 2017 19:44:42 +0000 Subject: [PATCH] mypy: Add annotations for help. --- tools/run-mypy | 2 ++ zulip_bots/zulip_bots/bots/help/help.py | 5 +++-- zulip_bots/zulip_bots/bots/help/test_help.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/run-mypy b/tools/run-mypy index 2e1d417..d09934a 100755 --- a/tools/run-mypy +++ b/tools/run-mypy @@ -44,6 +44,8 @@ force_include = [ "zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py", "zulip_bots/zulip_bots/bots/googlesearch/googlesearch.py", "zulip_bots/zulip_bots/bots/googlesearch/test_googlesearch.py", + "zulip_bots/zulip_bots/bots/help/help.py", + "zulip_bots/zulip_bots/bots/help/test_help.py", ] parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.") diff --git a/zulip_bots/zulip_bots/bots/help/help.py b/zulip_bots/zulip_bots/bots/help/help.py index 8bdd910..3d116b3 100644 --- a/zulip_bots/zulip_bots/bots/help/help.py +++ b/zulip_bots/zulip_bots/bots/help/help.py @@ -1,7 +1,8 @@ # See readme.md for instructions on running this code. +from typing import Any, Dict class HelpHandler(object): - def usage(self): + def usage(self: Any) -> str: return ''' This plugin will give info about Zulip to any user that types a message saying "help". @@ -11,7 +12,7 @@ class HelpHandler(object): your Zulip instance. ''' - def handle_message(self, message, bot_handler): + def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None: help_content = "Info on Zulip can be found here:\nhttps://github.com/zulip/zulip" bot_handler.send_reply(message, help_content) diff --git a/zulip_bots/zulip_bots/bots/help/test_help.py b/zulip_bots/zulip_bots/bots/help/test_help.py index 5ce8a7d..d6e6210 100755 --- a/zulip_bots/zulip_bots/bots/help/test_help.py +++ b/zulip_bots/zulip_bots/bots/help/test_help.py @@ -2,10 +2,12 @@ from zulip_bots.test_lib import StubBotTestCase +from typing import Any + class TestHelpBot(StubBotTestCase): bot_name = "help" - def test_bot(self): + def test_bot(self: Any) -> None: help_text = "Info on Zulip can be found here:\nhttps://github.com/zulip/zulip" requests = ["", "help", "Hi, my name is abc"]