bots/followup: Use Python 3 type mypy annotations.
This commit is contained in:
parent
1102057e35
commit
95b8ea4751
|
@ -36,6 +36,8 @@ exclude = [
|
||||||
force_include = [
|
force_include = [
|
||||||
# Include bots that we migrate to mypy.
|
# Include bots that we migrate to mypy.
|
||||||
"zulip_bots/zulip_bots/bots/helloworld/helloworld.py",
|
"zulip_bots/zulip_bots/bots/helloworld/helloworld.py",
|
||||||
|
"zulip_bots/zulip_bots/bots/followup/followup.py",
|
||||||
|
"zulip_bots/zulip_bots/bots/followup/test_followup.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.")
|
parser = argparse.ArgumentParser(description="Run mypy on files tracked by git.")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# See readme.md for instructions on running this code.
|
# See readme.md for instructions on running this code.
|
||||||
|
from typing import Dict, Any
|
||||||
|
|
||||||
class FollowupHandler(object):
|
class FollowupHandler(object):
|
||||||
'''
|
'''
|
||||||
|
@ -12,7 +13,7 @@ class FollowupHandler(object):
|
||||||
external issue tracker as well.
|
external issue tracker as well.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def usage(self):
|
def usage(self: Any) -> str:
|
||||||
return '''
|
return '''
|
||||||
This plugin will allow users to flag messages
|
This plugin will allow users to flag messages
|
||||||
as being follow-up items. Users should preface
|
as being follow-up items. Users should preface
|
||||||
|
@ -22,7 +23,7 @@ class FollowupHandler(object):
|
||||||
called "followup" that your API user can send to.
|
called "followup" that your API user can send to.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def handle_message(self, message, bot_handler):
|
def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None:
|
||||||
if message['content'] == '':
|
if message['content'] == '':
|
||||||
bot_response = "Please specify the message you want to send to followup stream after @mention-bot"
|
bot_response = "Please specify the message you want to send to followup stream after @mention-bot"
|
||||||
bot_handler.send_reply(message, bot_response)
|
bot_handler.send_reply(message, bot_response)
|
||||||
|
@ -35,7 +36,7 @@ class FollowupHandler(object):
|
||||||
content=bot_response,
|
content=bot_response,
|
||||||
))
|
))
|
||||||
|
|
||||||
def get_bot_followup_response(self, message):
|
def get_bot_followup_response(self: Any, message: Dict[str, str]) -> str:
|
||||||
original_content = message['content']
|
original_content = message['content']
|
||||||
original_sender = message['sender_email']
|
original_sender = message['sender_email']
|
||||||
temp_content = 'from %s: ' % (original_sender,)
|
temp_content = 'from %s: ' % (original_sender,)
|
||||||
|
|
|
@ -5,10 +5,12 @@ from __future__ import print_function
|
||||||
|
|
||||||
from zulip_bots.test_lib import BotTestCase
|
from zulip_bots.test_lib import BotTestCase
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
class TestFollowUpBot(BotTestCase):
|
class TestFollowUpBot(BotTestCase):
|
||||||
bot_name = "followup"
|
bot_name = "followup"
|
||||||
|
|
||||||
def test_bot(self):
|
def test_bot(self: Any) -> None:
|
||||||
expected_send_reply = [
|
expected_send_reply = [
|
||||||
("", 'Please specify the message you want to send to followup stream after @mention-bot')
|
("", 'Please specify the message you want to send to followup stream after @mention-bot')
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue