Browse Source

fixed return type hints in class _Persistence; added assertions fixing mypy errors

Fabian Peter Hammerle 3 years ago
parent
commit
a376482c1c
2 changed files with 9 additions and 4 deletions
  1. 3 0
      CHANGELOG.md
  2. 6 4
      location_guessing_game_telegram_bot/__init__.py

+ 3 - 0
CHANGELOG.md

@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- fixed return type hints in class `_Persistence`
+- added assertions fixing `mypy` errors
 
 ## [0.1.0] - 2021-02-14
 ### Added

+ 6 - 4
location_guessing_game_telegram_bot/__init__.py

@@ -61,6 +61,8 @@ def _photo_command(
     update: telegram.update.Update,
     context: telegram.ext.callbackcontext.CallbackContext,
 ):
+    assert isinstance(context.chat_data, dict)  # mypy
+    assert update.effective_chat is not None  # mypy
     if "last_photo_message_id" in context.chat_data:
         update.effective_chat.send_message(
             text="Lösung: {}".format(context.chat_data["last_photo"].description_url),
@@ -109,11 +111,11 @@ class _Persistence(telegram.ext.BasePersistence):
             store_bot_data=True, store_chat_data=False, store_user_data=False
         )
 
-    def get_user_data(self) -> dict:
-        return {}  # pragma: no cover
+    def get_user_data(self) -> typing.DefaultDict[int, dict]:
+        raise NotImplementedError()  # pragma: no cover
 
-    def get_chat_data(self) -> dict:
-        return {}  # pragma: no cover
+    def get_chat_data(self) -> typing.DefaultDict[int, dict]:
+        raise NotImplementedError()  # pragma: no cover
 
     def get_bot_data(self) -> dict:
         return self._bot_data