mypy: Avoid 'Any' for message in bots.
Also remove a few unnecessary typing imports.
This commit is contained in:
parent
7a95c31162
commit
4e19a7716d
|
@ -1,6 +1,6 @@
|
|||
# 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':
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# 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)
|
||||
|
||||
|
|
|
@ -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 ""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# 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':
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# 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)
|
||||
|
|
|
@ -2,7 +2,6 @@ import requests
|
|||
import logging
|
||||
import re
|
||||
import urllib
|
||||
from zulip_bots.lib import Any
|
||||
|
||||
from typing import Optional, Any, Dict
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
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 == '':
|
||||
|
|
Loading…
Reference in a new issue