diff options
author | Karthikeyan Singaravelan <tir.karthi@gmail.com> | 2021-08-29 13:49:45 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-29 11:19:45 +0300 |
commit | 8cfea4137851fa49c7d211b782800dd696b67c39 (patch) | |
tree | 92589b563cef92d1bf944ac5f590bbf8a8ab4d88 | |
parent | e19a76c58f2a998d86e51c5a2a0f1db37563efce (diff) | |
download | redis-py-8cfea4137851fa49c7d211b782800dd696b67c39.tar.gz |
Use Version instead of StrictVersion since distutils is deprecated. (#1552)
-rwxr-xr-x | redis/connection.py | 10 | ||||
-rw-r--r-- | tests/conftest.py | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/redis/connection.py b/redis/connection.py index e47e3c7..de30f0c 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -1,4 +1,4 @@ -from distutils.version import StrictVersion +from packaging.version import Version from itertools import chain from time import time from queue import LifoQueue, Empty, Full @@ -54,13 +54,13 @@ NONBLOCKING_EXCEPTIONS = tuple(NONBLOCKING_EXCEPTION_ERROR_NUMBERS.keys()) if HIREDIS_AVAILABLE: import hiredis - hiredis_version = StrictVersion(hiredis.__version__) + hiredis_version = Version(hiredis.__version__) HIREDIS_SUPPORTS_CALLABLE_ERRORS = \ - hiredis_version >= StrictVersion('0.1.3') + hiredis_version >= Version('0.1.3') HIREDIS_SUPPORTS_BYTE_BUFFER = \ - hiredis_version >= StrictVersion('0.1.4') + hiredis_version >= Version('0.1.4') HIREDIS_SUPPORTS_ENCODING_ERRORS = \ - hiredis_version >= StrictVersion('1.0.0') + hiredis_version >= Version('1.0.0') if not HIREDIS_SUPPORTS_BYTE_BUFFER: msg = ("redis-py works best with hiredis >= 0.1.4. You're running " diff --git a/tests/conftest.py b/tests/conftest.py index 711f9e5..fe304c2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ from redis.retry import Retry import pytest import random import redis -from distutils.version import StrictVersion +from packaging.version import Version from redis.connection import parse_url from unittest.mock import Mock from urllib.parse import urlparse @@ -44,7 +44,7 @@ def pytest_sessionstart(session): def skip_if_server_version_lt(min_version): redis_version = REDIS_INFO["version"] - check = StrictVersion(redis_version) < StrictVersion(min_version) + check = Version(redis_version) < Version(min_version) return pytest.mark.skipif( check, reason="Redis version required >= {}".format(min_version)) @@ -52,7 +52,7 @@ def skip_if_server_version_lt(min_version): def skip_if_server_version_gte(min_version): redis_version = REDIS_INFO["version"] - check = StrictVersion(redis_version) >= StrictVersion(min_version) + check = Version(redis_version) >= Version(min_version) return pytest.mark.skipif( check, reason="Redis version required < {}".format(min_version)) @@ -183,7 +183,7 @@ def wait_for_command(client, monitor, command): # if we find a command with our key before the command we're waiting # for, something went wrong redis_version = REDIS_INFO["version"] - if StrictVersion(redis_version) >= StrictVersion('5.0.0'): + if Version(redis_version) >= Version('5.0.0'): id_str = str(client.client_id()) else: id_str = '%08x' % random.randrange(2**32) |