Skip to content

Commit c523f0b

Browse files
committed
Change RedisModel.from_redis to Python 3 syntax from six; Format code
1 parent fa955da commit c523f0b

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

Diff for: aredis_om/model/model.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1179,14 +1179,10 @@ def find(cls, *expressions: Union[Any, Expression]) -> FindQuery:
11791179
@classmethod
11801180
def from_redis(cls, res: Any):
11811181
# TODO: Parsing logic copied from redisearch-py. Evaluate.
1182-
import six
1183-
from six.moves import xrange
1184-
from six.moves import zip as izip
1185-
11861182
def to_string(s):
1187-
if isinstance(s, six.string_types):
1183+
if isinstance(s, str):
11881184
return s
1189-
elif isinstance(s, six.binary_type):
1185+
elif isinstance(s, bytes):
11901186
return s.decode("utf-8", "ignore")
11911187
else:
11921188
return s # Not a string we care about
@@ -1195,12 +1191,12 @@ def to_string(s):
11951191
step = 2 # Because the result has content
11961192
offset = 1 # The first item is the count of total matches.
11971193

1198-
for i in xrange(1, len(res), step):
1194+
for i in range(1, len(res), step):
11991195
fields_offset = offset
12001196

12011197
fields = dict(
12021198
dict(
1203-
izip(
1199+
zip(
12041200
map(to_string, res[i + fields_offset][::2]),
12051201
map(to_string, res[i + fields_offset][1::2]),
12061202
)

Diff for: tests/test_hash_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from redis_om import has_redisearch
2626
from tests.conftest import py_test_mark_asyncio
2727

28+
2829
if not has_redisearch():
2930
pytestmark = pytest.mark.skip
3031

Diff for: tests/test_json_model.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from redis_om import has_redis_json
2828
from tests.conftest import py_test_mark_asyncio
2929

30+
3031
if not has_redis_json():
3132
pytestmark = pytest.mark.skip
3233

0 commit comments

Comments
 (0)