zulip-bots: Use context manager for incrementor.
MODIFY
zulip_bots/zulip_bots/bots/incrementor/incrementor.py
zulip_bots/zulip_bots/bots/incrementor/incrementor.py
# See readme.md for instructions on running this code.
from typing import Dict
-from zulip_bots.lib import BotHandler
+from zulip_bots.lib import BotHandler, use_storage
class IncrementorHandler:
META = {
@@ -24,8 +24,8 @@ class IncrementorHandler:
storage.put('message_id', None)
def handle_message(self, message: Dict[str, str], bot_handler: BotHandler) -> None:
- storage = bot_handler.storage
- num = storage.get('number')
+ with use_storage(bot_handler.storage, ['number']) as storage:
+ num = storage.get("number")
# num should already be an int, but we do `int()` to force an
# explicit type check

zulip-bots: Use context manager for incrementor.