From bea1b9871d35067b2ee34a3a796f1de5849bdc5d Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Tue, 19 Oct 2021 09:40:00 +0300 Subject: [PATCH] Removing packaging dependency distutils is built-in. --- redis/connection.py | 10 +++++----- tests/conftest.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/redis/connection.py b/redis/connection.py index 5528589026..c2fb84f205 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -1,4 +1,4 @@ -from packaging.version import Version +from distutils.version import LooseVersion from itertools import chain from time import time from queue import LifoQueue, Empty, Full @@ -54,13 +54,13 @@ if HIREDIS_AVAILABLE: import hiredis - hiredis_version = Version(hiredis.__version__) + hiredis_version = LooseVersion(hiredis.__version__) HIREDIS_SUPPORTS_CALLABLE_ERRORS = \ - hiredis_version >= Version('0.1.3') + hiredis_version >= LooseVersion('0.1.3') HIREDIS_SUPPORTS_BYTE_BUFFER = \ - hiredis_version >= Version('0.1.4') + hiredis_version >= LooseVersion('0.1.4') HIREDIS_SUPPORTS_ENCODING_ERRORS = \ - hiredis_version >= Version('1.0.0') + hiredis_version >= LooseVersion('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 3dc3ea149e..c099463807 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import pytest import random import redis -from packaging.version import Version +from distutils.version import LooseVersion from redis.connection import parse_url from unittest.mock import Mock from urllib.parse import urlparse @@ -38,7 +38,7 @@ def pytest_sessionstart(session): def skip_if_server_version_lt(min_version): redis_version = REDIS_INFO["version"] - check = Version(redis_version) < Version(min_version) + check = LooseVersion(redis_version) < LooseVersion(min_version) return pytest.mark.skipif( check, reason="Redis version required >= {}".format(min_version)) @@ -46,7 +46,7 @@ def skip_if_server_version_lt(min_version): def skip_if_server_version_gte(min_version): redis_version = REDIS_INFO["version"] - check = Version(redis_version) >= Version(min_version) + check = LooseVersion(redis_version) >= LooseVersion(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 Version(redis_version) >= Version('5.0.0'): + if LooseVersion(redis_version) >= LooseVersion('5.0.0'): id_str = str(client.client_id()) else: id_str = '%08x' % random.randrange(2**32)