From af65f515dc5526de6e1ec7ecc9da9c0637ae1d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 1 Oct 2024 15:39:12 +0000 Subject: [PATCH 1/4] drop python<=3.7 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. Filter all code over `pyupgracde --py38-plus`. Signed-off-by: Tomasz Kłoczko --- backoff/__init__.py | 1 - backoff/_async.py | 1 - backoff/_common.py | 2 -- backoff/_decorator.py | 1 - backoff/_jitter.py | 2 -- backoff/_sync.py | 1 - backoff/_typing.py | 12 +----------- backoff/types.py | 1 - tests/common.py | 1 - tests/test_backoff.py | 1 - tests/test_backoff_async.py | 2 -- tests/test_jitter.py | 1 - tests/test_types.py | 2 -- tests/test_wait_gen.py | 1 - 14 files changed, 1 insertion(+), 28 deletions(-) diff --git a/backoff/__init__.py b/backoff/__init__.py index eb7bfa6..5f1b2d4 100644 --- a/backoff/__init__.py +++ b/backoff/__init__.py @@ -1,4 +1,3 @@ -# coding:utf-8 """ Function decoration for backoff and retry diff --git a/backoff/_async.py b/backoff/_async.py index 82fd477..167dc3a 100644 --- a/backoff/_async.py +++ b/backoff/_async.py @@ -1,4 +1,3 @@ -# coding:utf-8 import datetime import functools import asyncio diff --git a/backoff/_common.py b/backoff/_common.py index 2b2e54e..52e45bb 100644 --- a/backoff/_common.py +++ b/backoff/_common.py @@ -1,5 +1,3 @@ -# coding:utf-8 - import functools import logging import sys diff --git a/backoff/_decorator.py b/backoff/_decorator.py index 77ed8c2..bdba4b9 100644 --- a/backoff/_decorator.py +++ b/backoff/_decorator.py @@ -1,4 +1,3 @@ -# coding:utf-8 import asyncio import logging import operator diff --git a/backoff/_jitter.py b/backoff/_jitter.py index be7e389..758d2a9 100644 --- a/backoff/_jitter.py +++ b/backoff/_jitter.py @@ -1,5 +1,3 @@ -# coding:utf-8 - import random diff --git a/backoff/_sync.py b/backoff/_sync.py index 4371e16..2904a97 100644 --- a/backoff/_sync.py +++ b/backoff/_sync.py @@ -1,4 +1,3 @@ -# coding:utf-8 import datetime import functools import time diff --git a/backoff/_typing.py b/backoff/_typing.py index 20446d4..d29a3a1 100644 --- a/backoff/_typing.py +++ b/backoff/_typing.py @@ -1,19 +1,9 @@ -# coding:utf-8 import logging import sys from typing import (Any, Callable, Coroutine, Dict, Generator, Sequence, Tuple, TypeVar, Union) -if sys.version_info >= (3, 8): # pragma: no cover - from typing import TypedDict -else: # pragma: no cover - # use typing_extensions if installed but don't require it - try: - from typing_extensions import TypedDict - except ImportError: - class TypedDict(dict): - def __init_subclass__(cls, **kwargs: Any) -> None: - return super().__init_subclass__() +from typing import TypedDict class _Details(TypedDict): diff --git a/backoff/types.py b/backoff/types.py index 25f20a4..39b9337 100644 --- a/backoff/types.py +++ b/backoff/types.py @@ -1,4 +1,3 @@ -# coding:utf-8 from ._typing import Details __all__ = [ diff --git a/tests/common.py b/tests/common.py index 56c2a8d..e9244f3 100644 --- a/tests/common.py +++ b/tests/common.py @@ -1,4 +1,3 @@ -# coding:utf-8 import collections import functools diff --git a/tests/test_backoff.py b/tests/test_backoff.py index cd33b63..883aaf3 100644 --- a/tests/test_backoff.py +++ b/tests/test_backoff.py @@ -1,4 +1,3 @@ -# coding:utf-8 import datetime import itertools import logging diff --git a/tests/test_backoff_async.py b/tests/test_backoff_async.py index 226ef08..732a64e 100644 --- a/tests/test_backoff_async.py +++ b/tests/test_backoff_async.py @@ -1,5 +1,3 @@ -# coding:utf-8 - import asyncio # Python 3.5 code and syntax is allowed in this file import random diff --git a/tests/test_jitter.py b/tests/test_jitter.py index 041b9fb..8193d0d 100644 --- a/tests/test_jitter.py +++ b/tests/test_jitter.py @@ -1,4 +1,3 @@ -# coding:utf-8 import backoff diff --git a/tests/test_types.py b/tests/test_types.py index 4e4b8cf..7f92041 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,5 +1,3 @@ -# coding:utf-8 - from backoff.types import Details diff --git a/tests/test_wait_gen.py b/tests/test_wait_gen.py index a658712..d7c5a7c 100644 --- a/tests/test_wait_gen.py +++ b/tests/test_wait_gen.py @@ -1,4 +1,3 @@ -# coding:utf-8 import backoff import math From 39439e8cea0f9490012b3558f3e3866c3b685ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 1 Oct 2024 15:43:52 +0000 Subject: [PATCH 2/4] filter all code over `ruff` to drop unused imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- backoff/_typing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backoff/_typing.py b/backoff/_typing.py index d29a3a1..2dcd3ed 100644 --- a/backoff/_typing.py +++ b/backoff/_typing.py @@ -1,5 +1,4 @@ import logging -import sys from typing import (Any, Callable, Coroutine, Dict, Generator, Sequence, Tuple, TypeVar, Union) From 464db2db5af6ecf8ef9de85ddfb325073a8414cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 1 Oct 2024 15:52:25 +0000 Subject: [PATCH 3/4] make iter() vs. itertools.repeat() code pyupgradeable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- backoff/_wait_gen.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backoff/_wait_gen.py b/backoff/_wait_gen.py index 33b37b8..c498c75 100644 --- a/backoff/_wait_gen.py +++ b/backoff/_wait_gen.py @@ -1,8 +1,11 @@ # coding:utf-8 -import itertools import math from typing import Any, Callable, Generator, Iterable, Optional, Union +from typing import Any +import sys +if sys.version_info < (3,12): + import itertools def expo( @@ -93,10 +96,10 @@ def constant( # Advance past initial .send() call yield # type: ignore[misc] - try: - itr = iter(interval) # type: ignore - except TypeError: + if sys.version_info < (3,12): itr = itertools.repeat(interval) # type: ignore + else: + itr = iter(interval) # type: ignore for val in itr: yield val From 421c0b9239f9cc90048566439cfc6170b06f5edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Tue, 1 Oct 2024 15:54:17 +0000 Subject: [PATCH 4/4] update pyproject.toml for python>=3.8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e0a6180..e2b01d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,11 @@ classifiers = ['Development Status :: 5 - Production/Stable', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Utilities'] @@ -27,7 +28,7 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.7" +python = ">=3.8" [tool.poetry.dev-dependencies] flake8 = "^4.0.1"