Skip to content

Commit 9908a4d

Browse files
authored
Run pyupgrade for 3.8 (#3236)
Run pyupgrade for 3.8.
1 parent 9a70f62 commit 9908a4d

File tree

12 files changed

+31
-43
lines changed

12 files changed

+31
-43
lines changed

redis/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys
1+
from importlib import metadata
22

33
from redis import asyncio # noqa
44
from redis.backoff import default_backoff
@@ -36,11 +36,6 @@
3636
)
3737
from redis.utils import from_url
3838

39-
if sys.version_info >= (3, 8):
40-
from importlib import metadata
41-
else:
42-
import importlib_metadata as metadata
43-
4439

4540
def int_or_str(value):
4641
try:

redis/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def clean_health_check_responses(self) -> None:
831831
else:
832832
raise PubSubError(
833833
"A non health check response was cleaned by "
834-
"execute_command: {0}".format(response)
834+
"execute_command: {}".format(response)
835835
)
836836
ttl -= 1
837837

redis/cluster.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,8 +1851,7 @@ def _sharded_message_generator(self):
18511851

18521852
def _pubsubs_generator(self):
18531853
while True:
1854-
for pubsub in self.node_pubsub_mapping.values():
1855-
yield pubsub
1854+
yield from self.node_pubsub_mapping.values()
18561855

18571856
def get_sharded_message(
18581857
self, ignore_subscribe_messages=False, timeout=0.0, target_node=None

redis/commands/bf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .info import BFInfo, CFInfo, CMSInfo, TDigestInfo, TopKInfo
66

77

8-
class AbstractBloom(object):
8+
class AbstractBloom:
99
"""
1010
The client allows to interact with RedisBloom and use all of
1111
it's functionality.

redis/commands/bf/info.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..helpers import nativestr
22

33

4-
class BFInfo(object):
4+
class BFInfo:
55
capacity = None
66
size = None
77
filterNum = None
@@ -26,7 +26,7 @@ def __getitem__(self, item):
2626
return getattr(self, item)
2727

2828

29-
class CFInfo(object):
29+
class CFInfo:
3030
size = None
3131
bucketNum = None
3232
filterNum = None
@@ -57,7 +57,7 @@ def __getitem__(self, item):
5757
return getattr(self, item)
5858

5959

60-
class CMSInfo(object):
60+
class CMSInfo:
6161
width = None
6262
depth = None
6363
count = None
@@ -72,7 +72,7 @@ def __getitem__(self, item):
7272
return getattr(self, item)
7373

7474

75-
class TopKInfo(object):
75+
class TopKInfo:
7676
k = None
7777
width = None
7878
depth = None
@@ -89,7 +89,7 @@ def __getitem__(self, item):
8989
return getattr(self, item)
9090

9191

92-
class TDigestInfo(object):
92+
class TDigestInfo:
9393
compression = None
9494
capacity = None
9595
merged_nodes = None

redis/commands/graph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ async def call_procedure(self, procedure, *args, read_only=False, **kwagrs):
252252
return await self.query(q, read_only=read_only)
253253

254254
async def labels(self):
255-
return ((await self.call_procedure(DB_LABELS, read_only=True))).result_set
255+
return (await self.call_procedure(DB_LABELS, read_only=True)).result_set
256256

257257
async def property_keys(self):
258258
return (await self.call_procedure(DB_PROPERTYKEYS, read_only=True)).result_set

redis/commands/json/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def set_file(
314314
315315
"""
316316

317-
with open(file_name, "r") as fp:
317+
with open(file_name) as fp:
318318
file_content = loads(fp.read())
319319

320320
return self.set(name, path, file_content, nx=nx, xx=xx, decode_keys=decode_keys)

redis/utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
import sys
32
from contextlib import contextmanager
43
from functools import wraps
54
from typing import Any, Dict, Mapping, Union
@@ -28,10 +27,7 @@
2827
except ImportError:
2928
CRYPTOGRAPHY_AVAILABLE = False
3029

31-
if sys.version_info >= (3, 8):
32-
from importlib import metadata
33-
else:
34-
import importlib_metadata as metadata
30+
from importlib import metadata
3531

3632

3733
def from_url(url, **kwargs):

tests/ssl_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def get_ssl_filename(name):
99
os.path.join(root, "..", "dockers", "stunnel", "keys")
1010
)
1111
if not os.path.isdir(cert_dir):
12-
raise IOError(f"No SSL certificates found. They should be in {cert_dir}")
12+
raise OSError(f"No SSL certificates found. They should be in {cert_dir}")
1313

1414
return os.path.join(cert_dir, name)

tests/test_asyncio/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
try:
55
mock.AsyncMock
66
except AttributeError:
7-
import mock
7+
from unittest import mock
88

99
try:
1010
from contextlib import aclosing

0 commit comments

Comments
 (0)