Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing packaging dependency #1626

Merged
merged 1 commit into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions redis/connection.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 "
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,15 +38,15 @@ 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))


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))
Expand Down Expand Up @@ -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)
Expand Down