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.
|
# See readme.md for instructions on running this code.
|
||||||
|
|
||||||
from typing import Any, List
|
from typing import Any, List, Dict
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
class BaremetricsHandler(object):
|
class BaremetricsHandler(object):
|
||||||
|
@ -46,7 +46,7 @@ class BaremetricsHandler(object):
|
||||||
Version 1.0
|
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()
|
message['content'] = message['content'].strip()
|
||||||
|
|
||||||
if message['content'].lower() == 'help':
|
if message['content'].lower() == 'help':
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# See readme.md for instructions on running this code.
|
# See readme.md for instructions on running this code.
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, Dict
|
||||||
|
|
||||||
class HelloWorldHandler(object):
|
class HelloWorldHandler(object):
|
||||||
def usage(self) -> str:
|
def usage(self) -> str:
|
||||||
|
@ -12,7 +12,7 @@ class HelloWorldHandler(object):
|
||||||
sophisticated, bots.
|
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
|
content = 'beep boop' # type: str
|
||||||
bot_handler.send_reply(message, content)
|
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.
|
new entry `something` for the product team.
|
||||||
''' + default_team_message
|
''' + 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))
|
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()
|
message_content = message['content'].strip().split()
|
||||||
if message_content == "":
|
if message_content == "":
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# See readme.md for instructions on running this code.
|
# See readme.md for instructions on running this code.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from typing import Any, List
|
from typing import Any, List, Dict
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
class MentionHandler(object):
|
class MentionHandler(object):
|
||||||
|
@ -34,7 +34,7 @@ class MentionHandler(object):
|
||||||
Version 1.00
|
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()
|
message['content'] = message['content'].strip()
|
||||||
|
|
||||||
if message['content'].lower() == 'help':
|
if message['content'].lower() == 'help':
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# See readme.md for instructions on running this code.
|
# See readme.md for instructions on running this code.
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
import simple_salesforce
|
import simple_salesforce
|
||||||
from typing import Dict, Any, List
|
from typing import Dict, Any, List
|
||||||
import getpass
|
import getpass
|
||||||
|
@ -165,7 +164,7 @@ class SalesforceHandler(object):
|
||||||
except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err:
|
except simple_salesforce.exceptions.SalesforceAuthenticationFailed as err:
|
||||||
bot_handler.quit('Failed to log in to Salesforce. {} {}'.format(err.code, err.message))
|
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:
|
try:
|
||||||
bot_response = self.get_salesforce_response(message['content'])
|
bot_response = self.get_salesforce_response(message['content'])
|
||||||
bot_handler.send_reply(message, bot_response)
|
bot_handler.send_reply(message, bot_response)
|
||||||
|
|
|
@ -2,7 +2,6 @@ import requests
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
from zulip_bots.lib import Any
|
|
||||||
|
|
||||||
from typing import Optional, Any, Dict
|
from typing import Optional, Any, Dict
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, List
|
from typing import Any, List, Dict
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TrelloHandler(object):
|
||||||
Use `list-commands` to get information about the supported commands.
|
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()
|
content = message['content'].strip()
|
||||||
|
|
||||||
if content == '':
|
if content == '':
|
||||||
|
|
Loading…
Reference in a new issue