zulip-bots: Add BotHandler Protocol.

- The `BotHandler` Protocol is a mypy Protocol
  s.t. all BotHandlers can use it as a default type.
- Fix ExternalBotHandler and StubBotHandler to
  follow `BotHandler` Protocol

Fixes part of #639
This commit is contained in:
LoopThrough-i-j 2021-03-04 01:14:25 +05:30 committed by Anders Kaseorg
parent 889e5e333d
commit a994c58439
2 changed files with 35 additions and 3 deletions

View file

@ -28,6 +28,7 @@ class StubBotHandler:
self.storage = SimpleStorage()
self.full_name = 'test-bot'
self.email = 'test-bot@example.com'
self.user_id = 0
self.message_server = SimpleMessageServer()
self.reset_transcript()
@ -69,7 +70,7 @@ class StubBotHandler:
def quit(self, message: str = "") -> None:
raise self.BotQuitException()
def get_config_info(self, bot_name: str, optional: bool = False) -> Dict[str, Any]:
def get_config_info(self, bot_name: str, optional: bool = False) -> Dict[str, str]:
return {}
def unique_reply(self) -> Dict[str, Any]: