zulip-bots: Add BotStorage
Protocol.
The `BotStorage` Protocol is created to add a common type to all storage classes. Note: Protocol is imported from `typing_extensions` as `typing` doesn't provide Protocol for python <= 3.7.
This commit is contained in:
parent
3887ad102e
commit
889e5e333d
|
@ -65,6 +65,7 @@ setuptools_info = dict(
|
|||
'html2text',
|
||||
'lxml',
|
||||
'BeautifulSoup4',
|
||||
'typing_extensions',
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import re
|
|||
|
||||
|
||||
from typing import Any, Optional, List, Dict, IO, Text
|
||||
|
||||
from typing_extensions import Protocol
|
||||
from zulip import Client, ZulipError
|
||||
|
||||
|
||||
|
@ -102,6 +102,16 @@ class BotIdentity:
|
|||
self.email = email
|
||||
self.mention = '@**' + name + '**'
|
||||
|
||||
class BotStorage(Protocol):
|
||||
def put(self, key: Text, value: Any) -> None:
|
||||
...
|
||||
|
||||
def get(self, key: Text) -> Any:
|
||||
...
|
||||
|
||||
def contains(self, key: Text) -> bool:
|
||||
...
|
||||
|
||||
class ExternalBotHandler:
|
||||
def __init__(
|
||||
self,
|
||||
|
|
Loading…
Reference in a new issue