zulip_bots: Get rid of unused imports and use python3 style for type annotations.
This commit is contained in:
parent
be5a7a8c4a
commit
f76287412c
|
@ -6,16 +6,12 @@ import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import re
|
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from contextlib import contextmanager
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from mypy_extensions import NoReturn
|
from mypy_extensions import NoReturn
|
||||||
from typing import Any, Optional, List, Dict, IO, Text, Set
|
from typing import Any, Optional, List, Dict, IO, Text
|
||||||
from types import ModuleType
|
|
||||||
|
|
||||||
from zulip import Client, ZulipError
|
from zulip import Client, ZulipError
|
||||||
from zulip_bots.custom_exceptions import ConfigValidationError
|
from zulip_bots.custom_exceptions import ConfigValidationError
|
||||||
|
@ -129,19 +125,16 @@ class ExternalBotHandler(object):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def storage(self):
|
def storage(self) -> StateHandler:
|
||||||
# type: () -> StateHandler
|
|
||||||
return self._storage
|
return self._storage
|
||||||
|
|
||||||
def send_message(self, message):
|
def send_message(self, message: (Dict[str, Any])) -> Dict[str, Any]:
|
||||||
# type: (Dict[str, Any]) -> Dict[str, Any]
|
|
||||||
if self._rate_limit.is_legal():
|
if self._rate_limit.is_legal():
|
||||||
return self._client.send_message(message)
|
return self._client.send_message(message)
|
||||||
else:
|
else:
|
||||||
self._rate_limit.show_error_and_exit()
|
self._rate_limit.show_error_and_exit()
|
||||||
|
|
||||||
def send_reply(self, message, response):
|
def send_reply(self, message: Dict[str, Any], response: str) -> Dict[str, Any]:
|
||||||
# type: (Dict[str, Any], str) -> Dict[str, Any]
|
|
||||||
if message['type'] == 'private':
|
if message['type'] == 'private':
|
||||||
return self.send_message(dict(
|
return self.send_message(dict(
|
||||||
type='private',
|
type='private',
|
||||||
|
@ -216,8 +209,7 @@ class ExternalBotHandler(object):
|
||||||
raise PermissionError("Cannot open file \"{}\". Bots may only access "
|
raise PermissionError("Cannot open file \"{}\". Bots may only access "
|
||||||
"files in their local directory.".format(abs_filepath))
|
"files in their local directory.".format(abs_filepath))
|
||||||
|
|
||||||
def quit(self, message = ""):
|
def quit(self, message: str="") -> None:
|
||||||
# type: (str) -> None
|
|
||||||
sys.exit(message)
|
sys.exit(message)
|
||||||
|
|
||||||
def extract_query_without_mention(message, client):
|
def extract_query_without_mention(message, client):
|
||||||
|
|
Loading…
Reference in a new issue