From aea575597d317930c00350cdda18e6acb3814958 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 1 Jan 2024 15:10:22 +0200 Subject: [PATCH] Partial clean up of Python 3.7 compatibility (#2928) * Drop typing_extensions dependency (not necessary when targeting Python 3.8+) * Bump python_requires to >=3.8, drop importlib-metadata shim dependency * Cease testing on Python 3.7 * Add 3.8 test --------- Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> --- .github/workflows/integration.yaml | 6 +++--- redis/_parsers/hiredis.py | 4 +--- redis/asyncio/client.py | 3 ++- redis/asyncio/connection.py | 3 ++- redis/commands/cluster.py | 2 +- redis/commands/core.py | 2 +- redis/compat.py | 6 ------ redis/typing.py | 3 +-- setup.py | 5 +---- 9 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 redis/compat.py diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 96b51fba..207d58fa 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -57,7 +57,7 @@ jobs: max-parallel: 15 fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9'] + python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy-3.8', 'pypy-3.9'] test-type: ['standalone', 'cluster'] connection-type: ['hiredis', 'plain'] env: @@ -111,7 +111,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.11'] + python-version: ['3.8', '3.11'] test-type: ['standalone', 'cluster'] connection-type: ['hiredis', 'plain'] protocol: ['3'] @@ -160,7 +160,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9'] + python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy-3.8', 'pypy-3.9'] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 diff --git a/redis/_parsers/hiredis.py b/redis/_parsers/hiredis.py index 1919d365..a52dbbd0 100644 --- a/redis/_parsers/hiredis.py +++ b/redis/_parsers/hiredis.py @@ -1,15 +1,13 @@ import asyncio import socket import sys -from typing import Callable, List, Optional, Union +from typing import Callable, List, Optional, TypedDict, Union if sys.version_info.major >= 3 and sys.version_info.minor >= 11: from asyncio import timeout as async_timeout else: from async_timeout import timeout as async_timeout -from redis.compat import TypedDict - from ..exceptions import ConnectionError, InvalidResponse, RedisError from ..typing import EncodableT from ..utils import HIREDIS_AVAILABLE diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index eea9612f..79689fcb 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -15,9 +15,11 @@ Mapping, MutableMapping, Optional, + Protocol, Set, Tuple, Type, + TypedDict, TypeVar, Union, cast, @@ -55,7 +57,6 @@ AsyncSentinelCommands, list_or_args, ) -from redis.compat import Protocol, TypedDict from redis.credentials import CredentialProvider from redis.exceptions import ( ConnectionError, diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 39f75a5f..df2bd20f 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -17,9 +17,11 @@ List, Mapping, Optional, + Protocol, Set, Tuple, Type, + TypedDict, TypeVar, Union, ) @@ -34,7 +36,6 @@ from redis.asyncio.retry import Retry from redis.backoff import NoBackoff -from redis.compat import Protocol, TypedDict from redis.connection import DEFAULT_RESP_VERSION from redis.credentials import CredentialProvider, UsernamePasswordCredentialProvider from redis.exceptions import ( diff --git a/redis/commands/cluster.py b/redis/commands/cluster.py index af3a717c..8dd463ed 100644 --- a/redis/commands/cluster.py +++ b/redis/commands/cluster.py @@ -7,13 +7,13 @@ Iterable, Iterator, List, + Literal, Mapping, NoReturn, Optional, Union, ) -from redis.compat import Literal from redis.crc import key_slot from redis.exceptions import RedisClusterException, RedisError from redis.typing import ( diff --git a/redis/commands/core.py b/redis/commands/core.py index 8fbd0d91..5d7b774d 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -12,6 +12,7 @@ Iterable, Iterator, List, + Literal, Mapping, Optional, Sequence, @@ -20,7 +21,6 @@ Union, ) -from redis.compat import Literal from redis.exceptions import ConnectionError, DataError, NoScriptError, RedisError from redis.typing import ( AbsExpiryT, diff --git a/redis/compat.py b/redis/compat.py deleted file mode 100644 index e4784934..00000000 --- a/redis/compat.py +++ /dev/null @@ -1,6 +0,0 @@ -# flake8: noqa -try: - from typing import Literal, Protocol, TypedDict # lgtm [py/unused-import] -except ImportError: - from typing_extensions import Literal # lgtm [py/unused-import] - from typing_extensions import Protocol, TypedDict diff --git a/redis/typing.py b/redis/typing.py index d1cd5568..a5d1369d 100644 --- a/redis/typing.py +++ b/redis/typing.py @@ -7,13 +7,12 @@ Awaitable, Iterable, Mapping, + Protocol, Type, TypeVar, Union, ) -from redis.compat import Protocol - if TYPE_CHECKING: from redis._parsers import Encoder from redis.asyncio.connection import ConnectionPool as AsyncConnectionPool diff --git a/setup.py b/setup.py index 8979b29b..89aa2e66 100644 --- a/setup.py +++ b/setup.py @@ -34,10 +34,8 @@ }, author="Redis Inc.", author_email="oss@redis.com", - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - 'importlib-metadata >= 1.0; python_version < "3.8"', - 'typing-extensions; python_version<"3.8"', 'async-timeout>=4.0.2; python_full_version<="3.11.2"', ], classifiers=[ @@ -49,7 +47,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10",