Browse Source

loosen version constraint for `python-telegram-bot` to restore compatibility with python3.5

reverts commit 19d9bad5de2a38f1c27b0f9f3d94d387ff963502
Fabian Peter Hammerle 3 years ago
parent
commit
8831e41734
6 changed files with 32 additions and 40 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 0
      Pipfile
  3. 12 32
      Pipfile.lock
  4. 4 2
      location_guessing_game_telegram_bot/__init__.py
  5. 6 4
      setup.py
  6. 5 2
      tests/test_photo_command.py

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 ### Fixed
+- loosen version constraint for `python-telegram-bot` to restore compatibility with python3.5
 - fixed return type hints in class `_Persistence`
 - added assertions fixing `mypy` errors
 - tests: fixed compatibility with python3.5-3.7

+ 4 - 0
Pipfile

@@ -6,6 +6,10 @@ name = "pypi"
 [packages]
 location-guessing-game-telegram-bot = {path = ".", editable = true}
 
+# python3.5 compatibility
+# https://github.com/python-telegram-bot/python-telegram-bot/commit/19a4f9e53a1798b886fd4ce3e5a9a48db9ae5152#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7L64
+python-telegram-bot = "<13"
+
 [dev-packages]
 # black requires python>=3.6
 # https://github.com/psf/black/commit/e74117f172e29e8a980e2c9de929ad50d3769150#diff-2eeaed663bd0d25b7e608891384b7298R51

+ 12 - 32
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "0f2a60732f30fd6ceba7215cb24f8b0f75fe93f9488226203a31ab09b3124052"
+            "sha256": "c4b2314ad0ccd42aa2bbe2c01daa1eb28b2b84cb175ce956268b4275e3324432"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -16,13 +16,6 @@
         ]
     },
     "default": {
-        "apscheduler": {
-            "hashes": [
-                "sha256:3bb5229eed6fbbdafc13ce962712ae66e175aa214c69bed35a06bffcf0c5e244",
-                "sha256:e8b1ecdb4c7cb2818913f766d5898183c7cb8936680710a4d3a966e02262e526"
-            ],
-            "version": "==3.6.3"
-        },
         "certifi": {
             "hashes": [
                 "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
@@ -84,6 +77,13 @@
             ],
             "version": "==3.4.5"
         },
+        "decorator": {
+            "hashes": [
+                "sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760",
+                "sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"
+            ],
+            "version": "==4.4.2"
+        },
         "location-guessing-game-telegram-bot": {
             "editable": true,
             "path": "."
@@ -97,24 +97,11 @@
         },
         "python-telegram-bot": {
             "hashes": [
-                "sha256:12adf52b59d7b23ba26b1f3e25ca95a4f850985ebf08a019bb7fd835c432929b",
-                "sha256:b87cdb2fca2983d4d49287c76ea64f13c5b786260bb742fe9a28334f20e6b2d3"
-            ],
-            "version": "==13.2"
-        },
-        "pytz": {
-            "hashes": [
-                "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da",
-                "sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"
-            ],
-            "version": "==2021.1"
-        },
-        "six": {
-            "hashes": [
-                "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
-                "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
+                "sha256:327186c56469216207dcdf8706892e58e0a62e51ef46f5143268e387bbb4edc3",
+                "sha256:7eebed539ccacf77896cff9e41d1f68746b8ff3ca4da1e2e59285e9c749cb050"
             ],
-            "version": "==1.15.0"
+            "index": "pypi",
+            "version": "==12.8"
         },
         "tornado": {
             "hashes": [
@@ -161,13 +148,6 @@
                 "sha256:fba85b6cd9c39be262fcd23865652920832b61583de2a2ca907dbd8e8a8c81e5"
             ],
             "version": "==6.1"
-        },
-        "tzlocal": {
-            "hashes": [
-                "sha256:643c97c5294aedc737780a49d9df30889321cbe1204eac2c2ec6134035a92e44",
-                "sha256:e2cb6c6b5b604af38597403e9852872d7f534962ae2954c7f35efcb1ccacf4a4"
-            ],
-            "version": "==2.1"
         }
     },
     "develop": {

+ 4 - 2
location_guessing_game_telegram_bot/__init__.py

@@ -69,8 +69,10 @@ def _photo_command(
             disable_web_page_preview=True,
             reply_to_message_id=context.chat_data["last_photo_message_id"],
         )
-        # https://github.com/python-telegram-bot/python-telegram-bot/pull/2043
-        update.effective_chat.send_location(
+        # telegram.chat.Chat.send_location shortcut added in v13.0
+        # https://github.com/python-telegram-bot/python-telegram-bot/commit/fc5844c13da3b3fb20bb2d0bfcdf1efb1a826ba6#diff-2590f2bde47ea3730442f14a3a029ef77d8f2c8f3186cf5edd7e18bcc7243c39R381
+        context.bot.send_location(
+            chat_id=update.effective_chat.id,
             latitude=context.chat_data["last_photo"].latitude,
             longitude=context.chat_data["last_photo"].longitude,
             disable_notification=True,

+ 6 - 4
setup.py

@@ -50,8 +50,8 @@ setuptools.setup(
         "Topic :: Games/Entertainment",
         # .github/workflows/python.yml TODO
         # "Programming Language :: Python :: 3.5",
-        # "Programming Language :: Python :: 3.6",
-        # "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
     ],
@@ -61,9 +61,11 @@ setuptools.setup(
         ]
     },
     install_requires=[
-        # >=13.0 telegram.chat.Chat.send_location shortcut
+        # >=13.0 provides telegram.chat.Chat.send_location shortcut
         # https://github.com/python-telegram-bot/python-telegram-bot/commit/fc5844c13da3b3fb20bb2d0bfcdf1efb1a826ba6#diff-2590f2bde47ea3730442f14a3a029ef77d8f2c8f3186cf5edd7e18bcc7243c39R381
-        "python-telegram-bot >= 13.0"
+        # however, >=13.0 requires python>=3.6
+        # https://github.com/python-telegram-bot/python-telegram-bot/commit/19a4f9e53a1798b886fd4ce3e5a9a48db9ae5152#diff-60f61ab7a8d1910d86d9fda2261620314edcae5894d5aaa236b821c7256badd7L64
+        "python-telegram-bot"
     ],
     setup_requires=["setuptools_scm"],
     tests_require=["pytest"],

+ 5 - 2
tests/test_photo_command.py

@@ -62,6 +62,7 @@ def test_send_solution_and_next_photo(caplog, wikimap_photos):
     update_mock.effective_chat.send_photo.return_value.message_id = (
         "second photo message id"
     )
+    update_mock.effective_chat.id = "chat id for send_location"
     context_mock = unittest.mock.MagicMock()
     context_mock.bot_data = {"photos": wikimap_photos[1:2]}
     context_mock.chat_data = {
@@ -82,8 +83,10 @@ def test_send_solution_and_next_photo(caplog, wikimap_photos):
         disable_web_page_preview=True,
         reply_to_message_id="first photo message id",
     )
-    update_mock.effective_chat.send_location.assert_called_once_with(
-        # float comparison? :O
+    # update_mock.effective_chat.send_location.assert_called_once_with(
+    context_mock.bot.send_location.assert_called_once_with(
+        chat_id="chat id for send_location",
+        # float comparison? :o
         latitude=47.288805,
         longitude=12.144116,
         disable_notification=True,