Skip to content

Commit 9ec9e83

Browse files
committed
general codebase refactor
Signed-off-by: wiseaidev <[email protected]>
1 parent dcd84e0 commit 9ec9e83

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

aredis_om/model/model.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def is_supported_container_type(typ: Optional[type]) -> bool:
117117

118118

119119
def validate_model_fields(model: Type["RedisModel"], field_values: Dict[str, Any]):
120-
for field_name in field_values.keys():
120+
for field_name in field_values:
121121
if "__" in field_name:
122122
obj = model
123123
for sub_field in field_name.split("__"):
@@ -567,7 +567,7 @@ def resolve_value(
567567
# The value contains the TAG field separator. We can work
568568
# around this by breaking apart the values and unioning them
569569
# with multiple field:{} queries.
570-
values: filter = filter(None, value.split(separator_char))
570+
values: List[str] = [val for val in value.split(separator_char) if val]
571571
for value in values:
572572
value = escaper.escape(value)
573573
result += f"@{field_name}:{{{value}}}"
@@ -1195,12 +1195,12 @@ def to_string(s):
11951195
step = 2 # Because the result has content
11961196
offset = 1 # The first item is the count of total matches.
11971197

1198-
for i in xrange(1, len(res), step):
1198+
for i in range(1, len(res), step):
11991199
fields_offset = offset
12001200

12011201
fields = dict(
12021202
dict(
1203-
izip(
1203+
zip(
12041204
map(to_string, res[i + fields_offset][::2]),
12051205
map(to_string, res[i + fields_offset][1::2]),
12061206
)
@@ -1633,7 +1633,7 @@ def schema_for_type(
16331633
parent_type=typ,
16341634
)
16351635
)
1636-
return " ".join(filter(None, sub_fields))
1636+
return " ".join([sub_field for sub_field in sub_fields if sub_field])
16371637
# NOTE: This is the termination point for recursion. We've descended
16381638
# into models and lists until we found an actual value to index.
16391639
elif should_index:

aredis_om/model/render_tree.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def render_tree(
3333

3434
if up is not None:
3535
next_last = "up"
36-
next_indent = "{0}{1}{2}".format(
37-
indent, " " if "up" in last else "|", " " * len(str(name(current_node)))
38-
)
36+
next_indent = f'{indent}{" " if "up" in last else "|"}{" " * len(str(name(current_node)))}'
3937
render_tree(
4038
up, nameattr, left_child, right_child, next_indent, next_last, buffer
4139
)
@@ -59,14 +57,14 @@ def render_tree(
5957
end_shape = ""
6058

6159
print(
62-
"{0}{1}{2}{3}".format(indent, start_shape, name(current_node), end_shape),
60+
f"{indent}{start_shape}{name(current_node)}{end_shape}",
6361
file=buffer,
6462
)
6563

6664
if down is not None:
6765
next_last = "down"
68-
next_indent = "{0}{1}{2}".format(
69-
indent, " " if "down" in last else "|", " " * len(str(name(current_node)))
66+
next_indent = (
67+
f'{indent}{" " if "down" in last else "|"}{len(str(name(current_node)))}'
7068
)
7169
render_tree(
7270
down, nameattr, left_child, right_child, next_indent, next_last, buffer

tests/test_oss_redis_features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async def members(m):
8080
async def test_all_keys(members, m):
8181
pks = sorted([pk async for pk in await m.Member.all_pks()])
8282
assert len(pks) == 3
83-
assert pks == sorted([m.pk for m in members])
83+
assert pks == sorted(m.pk for m in members)
8484

8585

8686
@py_test_mark_asyncio

0 commit comments

Comments
 (0)