diff --git a/python/pyproject.toml b/python/pyproject.toml index e25ffc3dc8..4f4e79b91d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -6,8 +6,8 @@ build-backend = "maturin" name = "valkey-glide" requires-python = ">=3.8" dependencies = [ - "async-timeout>=4.0.2", - "typing-extensions>=4.8.0", + "async-timeout>=4.0.2; python_version < '3.11'", + "typing-extensions>=4.8.0; python_version < '3.11'", "protobuf>=3.20" ] classifiers = [ diff --git a/python/python/glide/glide_client.py b/python/python/glide/glide_client.py index d2bc355542..f53644fa3d 100644 --- a/python/python/glide/glide_client.py +++ b/python/python/glide/glide_client.py @@ -5,7 +5,6 @@ import threading from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast -import async_timeout from glide.async_commands.cluster_commands import ClusterCommands from glide.async_commands.command_args import ObjectType from glide.async_commands.core import CoreCommands @@ -27,7 +26,6 @@ from glide.protobuf.response_pb2 import RequestErrorType, Response from glide.protobuf_codec import PartialMessageException, ProtobufCodec from glide.routes import Route, set_protobuf_route -from typing_extensions import Self from .glide import ( DEFAULT_TIMEOUT_IN_MILLISECONDS, @@ -38,6 +36,13 @@ value_from_pointer, ) +if sys.version_info >= (3, 11): + import asyncio as async_timeout + from typing import Self +else: + import async_timeout + from typing_extensions import Self + def get_request_error_class( error_type: Optional[RequestErrorType.ValueType], diff --git a/python/requirements.txt b/python/requirements.txt index eaf623c8a5..63b2be3603 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,7 +1,7 @@ -async-timeout==4.0.2 +async-timeout==4.0.2;python_version<"3.11" maturin==0.13.0 protobuf==3.20.* pytest==7.1.2 pytest-asyncio==0.19.0 -typing_extensions==4.8.0 +typing_extensions==4.8.0;python_version<"3.11" pytest-html