Skip to content

Commit ebeb7be

Browse files
committed
Replace distutils.versions with packaging.versions
This removes `DeprecationWarnings` raised by `distutils`. Fixes aio-libs-abandoned#1306
1 parent 19be499 commit ebeb7be

File tree

4 files changed

+89
-7
lines changed

4 files changed

+89
-7
lines changed

CHANGES/1306.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replace `disutils.version.StrictVersion` with `packaging.version.parse` implementation

aioredis/connection.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import ssl
99
import threading
1010
import warnings
11-
from distutils.version import StrictVersion
1211
from itertools import chain
1312
from types import MappingProxyType
1413
from typing import (
@@ -28,6 +27,7 @@
2827
from urllib.parse import ParseResult, parse_qs, unquote, urlparse
2928

3029
import async_timeout
30+
from packaging.version import parse as parse_version
3131

3232
from .compat import Protocol, TypedDict
3333
from .exceptions import (
@@ -65,8 +65,8 @@
6565
HIREDIS_AVAILABLE = False
6666
else:
6767
HIREDIS_AVAILABLE = True
68-
hiredis_version = StrictVersion(hiredis.__version__)
69-
if hiredis_version < StrictVersion("1.0.0"):
68+
hiredis_version = parse_version(hiredis.__version__)
69+
if hiredis_version < parse_version("1.0.0"):
7070
warnings.warn(
7171
"aioredis supports hiredis @ 1.0.0 or higher. "
7272
f"You have hiredis @ {hiredis.__version__}. "

docs/changelog.md

+81
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,87 @@
22

33
# Changelog
44

5+
### Features
6+
7+
- Replace PubSub.run_in_thread with a coroutine PubSub.run.
8+
(see #1007)
9+
- Add redis-py commit bc5854217b4e94eb7a33e3da5738858a17135ca5
10+
(see #1036)
11+
- Add redis-py commit https://github.com/andymccurdy/redis-py/commit/c7e26ae6749f63b9ebf65c023f270b2ea2b9536a
12+
(see #1037)
13+
- Introduce issue forms
14+
(see #1080)
15+
- Add auto_close_connection_pool for Redis-created connection pools, not manually created pools
16+
(see #1256)
17+
- Using coroutines as callbacks is now possible.
18+
(see #1284)
19+
- Replace `disutils.version.StrictVersion` with `packaging.version.parse` implementation
20+
(see #1306)
21+
22+
23+
### Bugfixes
24+
25+
- removed socket timeout setup
26+
(see #951)
27+
- Fix a number of type annotations. The majority of the changes are to allow keys
28+
to be specified as `bytes`, but other errors have been corrected too.
29+
(see #1008)
30+
- Fix aioredis.lock.Lock using a sleep that blocks the event loop.
31+
(see #1016)
32+
- include CHANGELOG.md in the sdist
33+
(see #1043)
34+
- Skip testing with pypy and uvloop
35+
(see #1045)
36+
- Set socket_connect_timeout in UnixDomainSocketConnection. Change `_connect` in UnixDomainSocketConnection to use socket_connect_timeout instead of socket_timeout.
37+
(see #1060)
38+
- Rename the health check
39+
(see #1065)
40+
- Adds a lock to ``aioredis.connection.ConnectionPool``
41+
(see #1068)
42+
- Fix type annotations: added `typing.Optional` for values with default `None`.
43+
(see #1083)
44+
- Restore mkdocs-autorefs to version 0.2.1 to remain compatible with mkdocstrings.
45+
(see #1084)
46+
- Synchronized reading the responses from a connection
47+
(see #1105)
48+
- fixed raw socket.error (or one of its subclasses) raises instead of a redis.exceptions.ConnectionError
49+
(see #1129)
50+
- Fix type annotation of `socket_keepalive_options` arguments when creating connections and clients
51+
(see #1141)
52+
- Fix buffer is closed error when using PythonParser class
53+
(see #1212)
54+
- Fix typing on evalsha keys_and_args argument
55+
(see #1214)
56+
- Fix typing on blpop (etc) timeout argument
57+
(see #1224)
58+
- Change `__del__` in Redis to raise ResourceWarning (Fixes #1115)
59+
(see #1227)
60+
- Instantiate lock on UnixDomainSocketConnection init.
61+
(see #1249)
62+
63+
64+
### Improved Documentation
65+
66+
- Document breaking API changes in redis 2.x.
67+
(see #1109)
68+
- Fix errors in getting started examples; Unify style of getting started examples with other examples.
69+
(see #1159)
70+
- Add the rest of the requirements
71+
(see #1167)
72+
73+
74+
### Deprecations and Removals
75+
76+
- Remove explicit loop arguments from connection classes.
77+
Add loop argument to PubSub.run_in_thread.
78+
(see #1002)
79+
80+
81+
### Misc
82+
83+
- #930, #940, #1003, #1018, #1095, #1101, #1219, #1247, #1302
84+
85+
586
## 2.0.0a1 - (2021-06-18)
687

788
### Bugfixes

tests/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import argparse
22
import asyncio
33
import random
4-
from distutils.version import StrictVersion
54
from typing import Callable, TypeVar
65
from urllib.parse import urlparse
76

87
import pytest
8+
from packaging.version import parse as parse_version
99

1010
import aioredis
1111
from aioredis.client import Monitor
@@ -117,13 +117,13 @@ def pytest_sessionstart(session):
117117

118118
def skip_if_server_version_lt(min_version: str) -> _TestDecorator:
119119
redis_version = REDIS_INFO["version"]
120-
check = StrictVersion(redis_version) < StrictVersion(min_version)
120+
check = parse_version(redis_version) < parse_version(min_version)
121121
return pytest.mark.skipif(check, reason=f"Redis version required >= {min_version}")
122122

123123

124124
def skip_if_server_version_gte(min_version: str) -> _TestDecorator:
125125
redis_version = REDIS_INFO["version"]
126-
check = StrictVersion(redis_version) >= StrictVersion(min_version)
126+
check = parse_version(redis_version) >= parse_version(min_version)
127127
return pytest.mark.skipif(check, reason=f"Redis version required < {min_version}")
128128

129129

@@ -301,7 +301,7 @@ async def wait_for_command(client: aioredis.Redis, monitor: Monitor, command: st
301301
# if we find a command with our key before the command we're waiting
302302
# for, something went wrong
303303
redis_version = REDIS_INFO["version"]
304-
if StrictVersion(redis_version) >= StrictVersion("5.0.0"):
304+
if parse_version(redis_version) >= parse_version("5.0.0"):
305305
id_str = str(await client.client_id())
306306
else:
307307
id_str = "%08x" % random.randrange(2**32)

0 commit comments

Comments
 (0)