Selaa lähdekoodia

drop python3.10, adopt python3.11 features

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fabian Peter Hammerle 4 päivää sitten
vanhempi
sitoutus
77199d125e
7 muutettua tiedostoa jossa 11 lisäystä ja 85 poistoa
  1. 0 1
      .github/workflows/python.yml
  2. 1 0
      .gitignore
  3. 2 2
      CHANGELOG.md
  4. 0 10
      Pipfile
  5. 1 64
      Pipfile.lock
  6. 4 5
      location_guessing_game_telegram_bot/__init__.py
  7. 3 3
      setup.py

+ 0 - 1
.github/workflows/python.yml

@@ -34,7 +34,6 @@ jobs:
     strategy:
       matrix:
         python-version:
-        - '3.10'
         - '3.11'
         - '3.12'
       fail-fast: false

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 /*.egg-info/
+/.coverage
 /.eggs/
 /.mypy_cache/
 /.pytest_cache/

+ 2 - 2
CHANGELOG.md

@@ -13,8 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
   (by manually setting build argument `SETUPTOOLS_SCM_PRETEND_VERSION`)
 
 ### Removed
-- compatibility with `python3.5`, `python3.6`, `python3.7`, `python3.8`
-  & `python3.9`
+- compatibility with `python3.5`, `python3.6`, `python3.7`, `python3.8`,
+  `python3.9` & `python3.10`
 
 ## [0.1.1] - 2021-02-14
 ### Fixed

+ 0 - 10
Pipfile

@@ -25,16 +25,6 @@ pylint = "*"
 pytest = "*"
 pytest-cov = "*"
 
-# python3.10 compatibility
-# >    File "[...]/lib/python3.10/site-packages/_pytest/_code/code.py", line 60, in <module>
-# >     from exceptiongroup import BaseExceptionGroup
-# > ModuleNotFoundError: No module named 'exceptiongroup'
-exceptiongroup = {markers = "python_version < '3.11'"}
-# >   File "[...]/lib/python3.10/site-packages/_pytest/config/findpaths.py", line 71, in load_config_dict_from_file
-# >     import tomli as tomllib
-# > ModuleNotFoundError: No module named 'tomli'
-tomli = {markers = "python_version < '3.11'"}
-
 # > tests/conftest.py:24: in <module>
 # >     from location_guessing_game_telegram_bot import _Photo
 # > location_guessing_game_telegram_bot/__init__.py:30: in <module>

+ 1 - 64
Pipfile.lock

@@ -1,7 +1,7 @@
 {
     "_meta": {
         "hash": {
-            "sha256": "e6bc1b11ae8ad6e43e2edc2ce30f64595e169625e23082a58a236cacefeb7835"
+            "sha256": "23494abf2cbaa203ea4e974e66b82a3746689ddc2461e7bd0660ffafefa6bf02"
         },
         "pipfile-spec": 6,
         "requires": {
@@ -381,15 +381,6 @@
             "index": "pypi",
             "version": "==0.4.1"
         },
-        "exceptiongroup": {
-            "hashes": [
-                "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219",
-                "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598"
-            ],
-            "index": "pypi",
-            "markers": "python_version < '3.11'",
-            "version": "==1.3.1"
-        },
         "iniconfig": {
             "hashes": [
                 "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730",
@@ -770,60 +761,6 @@
             "markers": "python_version >= '3.8'",
             "version": "==0.4.1"
         },
-        "tomli": {
-            "hashes": [
-                "sha256:01f520d4f53ef97964a240a035ec2a869fe1a37dde002b57ebc4417a27ccd853",
-                "sha256:0d85819802132122da43cb86656f8d1f8c6587d54ae7dcaf30e90533028b49fe",
-                "sha256:136443dbd7e1dee43c68ac2694fde36b2849865fa258d39bf822c10e8068eac5",
-                "sha256:1d8591993e228b0c930c4bb0db464bdad97b3289fb981255d6c9a41aedc84b2d",
-                "sha256:2190f2e9dd7508d2a90ded5ed369255980a1bcdd58e52f7fe24b8162bf9fedbd",
-                "sha256:2c1c351919aca02858f740c6d33adea0c5deea37f9ecca1cc1ef9e884a619d26",
-                "sha256:36d2bd2ad5fb9eaddba5226aa02c8ec3fa4f192631e347b3ed28186d43be6b54",
-                "sha256:3d48a93ee1c9b79c04bb38772ee1b64dcf18ff43085896ea460ca8dec96f35f6",
-                "sha256:47149d5bd38761ac8be13a84864bf0b7b70bc051806bc3669ab1cbc56216b23c",
-                "sha256:4ab97e64ccda8756376892c53a72bd1f964e519c77236368527f758fbc36a53a",
-                "sha256:4b605484e43cdc43f0954ddae319fb75f04cc10dd80d830540060ee7cd0243cd",
-                "sha256:504aa796fe0569bb43171066009ead363de03675276d2d121ac1a4572397870f",
-                "sha256:51529d40e3ca50046d7606fa99ce3956a617f9b36380da3b7f0dd3dd28e68cb5",
-                "sha256:52c8ef851d9a240f11a88c003eacb03c31fc1c9c4ec64a99a0f922b93874fda9",
-                "sha256:559db847dc486944896521f68d8190be1c9e719fced785720d2216fe7022b662",
-                "sha256:5a881ab208c0baf688221f8cecc5401bd291d67e38a1ac884d6736cbcd8247e9",
-                "sha256:5cb41aa38891e073ee49d55fbc7839cfdb2bc0e600add13874d048c94aadddd1",
-                "sha256:5e262d41726bc187e69af7825504c933b6794dc3fbd5945e41a79bb14c31f585",
-                "sha256:5ee18d9ebdb417e384b58fe414e8d6af9f4e7a0ae761519fb50f721de398dd4e",
-                "sha256:7008df2e7655c495dd12d2a4ad038ff878d4ca4b81fccaf82b714e07eae4402c",
-                "sha256:734e20b57ba95624ecf1841e72b53f6e186355e216e5412de414e3c51e5e3c41",
-                "sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f",
-                "sha256:7f86fd587c4ed9dd76f318225e7d9b29cfc5a9d43de44e5754db8d1128487085",
-                "sha256:7f94b27a62cfad8496c8d2513e1a222dd446f095fca8987fceef261225538a15",
-                "sha256:88dceee75c2c63af144e456745e10101eb67361050196b0b6af5d717254dddf7",
-                "sha256:8a650c2dbafa08d42e51ba0b62740dae4ecb9338eefa093aa5c78ceb546fcd5c",
-                "sha256:8d65a2fbf9d2f8352685bc1364177ee3923d6baf5e7f43ea4959d7d8bc326a36",
-                "sha256:96481a5786729fd470164b47cdb3e0e58062a496f455ee41b4403be77cb5a076",
-                "sha256:a120733b01c45e9a0c34aeef92bf0cf1d56cfe81ed9d47d562f9ed591a9828ac",
-                "sha256:b1d22e6e9387bf4739fbe23bfa80e93f6b0373a7f1b96c6227c32bef95a4d7a8",
-                "sha256:b8c198f8c1805dc42708689ed6864951fd2494f924149d3e4bce7710f8eb5232",
-                "sha256:c2541745709bad0264b7d4705ad453b76ccd191e64aa6f0fc66b69a293a45ece",
-                "sha256:c742f741d58a28940ce01d58f0ab2ea3ced8b12402f162f4d534dfe18ba1cd6a",
-                "sha256:c7f2c7f2b9ca6bdeef8f0fa897f8e05085923eb091721675170254cbc5b02897",
-                "sha256:d312ef37c91508b0ab2cee7da26ec0b3ed2f03ce12bd87a588d771ae15dcf82d",
-                "sha256:d4d8fe59808a54658fcc0160ecfb1b30f9089906c50b23bcb4c69eddc19ec2b4",
-                "sha256:da25dc3563bff5965356133435b757a795a17b17d01dbc0f42fb32447ddfd917",
-                "sha256:eab21f45c7f66c13f2a9e0e1535309cee140182a9cdae1e041d02e47291e8396",
-                "sha256:eb0dc4e38e6a1fd579e5d50369aa2e10acfc9cace504579b2faabb478e76941a",
-                "sha256:ec9bfaf3ad2df51ace80688143a6a4ebc09a248f6ff781a9945e51937008fcbc",
-                "sha256:ede3e6487c5ef5d28634ba3f31f989030ad6af71edfb0055cbbd14189ff240ba",
-                "sha256:f3c6818a1a86dd6dca7ddcaaf76947d5ba31aecc28cb1b67009a5877c9a64f3f",
-                "sha256:f758f1b9299d059cc3f6546ae2af89670cb1c4d48ea29c3cacc4fe7de3058257",
-                "sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30",
-                "sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf",
-                "sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9",
-                "sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049"
-            ],
-            "index": "pypi",
-            "markers": "python_version < '3.11'",
-            "version": "==2.4.1"
-        },
         "tomlkit": {
             "hashes": [
                 "sha256:177a05aece5a8ca5266fd3c448abb47b8d352f09d477d3ca8332db4d89b24304",

+ 4 - 5
location_guessing_game_telegram_bot/__init__.py

@@ -15,8 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-from __future__ import annotations
-
 import argparse
 import collections
 import dataclasses
@@ -25,6 +23,7 @@ import logging
 import os
 import pathlib
 import random
+import typing
 import urllib.request
 
 import telegram.ext
@@ -44,7 +43,7 @@ class _Photo:
         return "photo " + self.description_url
 
     @classmethod
-    def from_wikimap_export(cls, data: dict) -> _Photo:
+    def from_wikimap_export(cls, data: dict) -> typing.Self:
         # pylint: disable=consider-ternary-expression; easier to read
         if isinstance(data["coordinates"], list):
             coords = data["coordinates"][0]
@@ -115,10 +114,10 @@ class _Persistence(telegram.ext.BasePersistence):
             store_bot_data=True, store_chat_data=False, store_user_data=False
         )
 
-    def get_user_data(self) -> collections.defaultdict[int, dict]:
+    def get_user_data(self) -> typing.Never:
         raise NotImplementedError()  # pragma: no cover
 
-    def get_chat_data(self) -> collections.defaultdict[int, dict]:
+    def get_chat_data(self) -> typing.Never:
         raise NotImplementedError()  # pragma: no cover
 
     def get_bot_data(self) -> dict:

+ 3 - 3
setup.py

@@ -53,7 +53,6 @@ setuptools.setup(
         "Operating System :: OS Independent",
         "Topic :: Games/Entertainment",
         # .github/workflows/python.yml
-        "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3.11",
         "Programming Language :: Python :: 3.12",
     ],
@@ -63,10 +62,11 @@ setuptools.setup(
         ]
     },
     # >=3.6 f-strings & force kwargs with *
-    # >=3.7 postponed evaluation of type annotations (PEP563) & dataclass
+    # >=3.7 dataclass
     # >=3.9 type hints list[…] & collections.defaultdict[…] (PEP585)
     # >=3.10 union types as X | Y (PEP604)
-    python_requires=">=3.10",
+    # >=3.11 typing.Self & typing.Never
+    python_requires=">=3.11",
     install_requires=[
         # >=13.0 provides telegram.chat.Chat.send_location shortcut
         # https://github.com/python-telegram-bot/python-telegram-bot/commit/fc5844c13da3b3fb20bb2d0bfcdf1efb1a826ba6#diff-2590f2bde47ea3730442f14a3a029ef77d8f2c8f3186cf5edd7e18bcc7243c39R381