mypy: Avoid 'Any' for message in bots.
Also remove a few unnecessary typing imports.
MODIFY
zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py
zulip_bots/zulip_bots/bots/baremetrics/baremetrics.py
# See readme.md for instructions on running this code.
-from typing import Any, List
+from typing import Any, List, Dict
import requests
class BaremetricsHandler(object):
@@ -46,7 +46,7 @@ class BaremetricsHandler(object):
Version 1.0
'''
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
message['content'] = message['content'].strip()
if message['content'].lower() == 'help':

MODIFY
zulip_bots/zulip_bots/bots/helloworld/helloworld.py
zulip_bots/zulip_bots/bots/helloworld/helloworld.py
# See readme.md for instructions on running this code.
-from typing import Any
+from typing import Any, Dict
class HelloWorldHandler(object):
def usage(self) -> str:
@@ -12,7 +12,7 @@ class HelloWorldHandler(object):
sophisticated, bots.
'''
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
content = 'beep boop' # type: str
bot_handler.send_reply(message, content)

MODIFY
zulip_bots/zulip_bots/bots/idonethis/idonethis.py
zulip_bots/zulip_bots/bots/idonethis/idonethis.py
@@ -180,10 +180,10 @@ Below are some of the commands you can use, and what they do.
new entry `something` for the product team.
''' + default_team_message
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
bot_handler.send_reply(message, self.get_response(message))
- def get_response(self, message: Any) -> str:
+ def get_response(self, message: Dict[str, Any]) -> str:
message_content = message['content'].strip().split()
if message_content == "":
return ""

MODIFY
zulip_bots/zulip_bots/bots/mention/mention.py
zulip_bots/zulip_bots/bots/mention/mention.py
# See readme.md for instructions on running this code.
import requests
-from typing import Any, List
+from typing import Any, List, Dict
import logging
class MentionHandler(object):
@@ -34,7 +34,7 @@ class MentionHandler(object):
Version 1.00
'''
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
message['content'] = message['content'].strip()
if message['content'].lower() == 'help':

MODIFY
zulip_bots/zulip_bots/bots/salesforce/salesforce.py
zulip_bots/zulip_bots/bots/salesforce/salesforce.py
# See readme.md for instructions on running this code.
-from typing import Any
import simple_salesforce
from typing import Dict, Any, List
import getpass
@@ -165,7 +164,7 @@ class SalesforceHandler(object):
except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err:
bot_handler.quit('Failed to log in to Salesforce. {} {}'.format(err.code, err.message))
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
try:
bot_response = self.get_salesforce_response(message['content'])
bot_handler.send_reply(message, bot_response)

MODIFY
zulip_bots/zulip_bots/bots/stack_overflow/stack_overflow.py
zulip_bots/zulip_bots/bots/stack_overflow/stack_overflow.py
@@ -2,7 +2,6 @@ import requests
import logging
import re
import urllib
-from zulip_bots.lib import Any
from typing import Optional, Any, Dict

MODIFY
zulip_bots/zulip_bots/bots/trello/trello.py
zulip_bots/zulip_bots/bots/trello/trello.py
-from typing import Any, List
+from typing import Any, List, Dict
import requests
@@ -42,7 +42,7 @@ class TrelloHandler(object):
Use `list-commands` to get information about the supported commands.
'''
- def handle_message(self, message: Any, bot_handler: Any) -> None:
+ def handle_message(self, message: Dict[str, Any], bot_handler: Any) -> None:
content = message['content'].strip()
if content == '':

mypy: Avoid 'Any' for message in bots.

Also remove a few unnecessary typing imports.