Skip to content

Commit

Permalink
general codebase refactor
Browse files Browse the repository at this point in the history
Signed-off-by: wiseaidev <[email protected]>
  • Loading branch information
wiseaidev committed Aug 6, 2022
1 parent dcd84e0 commit 9ec9e83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def is_supported_container_type(typ: Optional[type]) -> bool:


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

for i in xrange(1, len(res), step):
for i in range(1, len(res), step):
fields_offset = offset

fields = dict(
dict(
izip(
zip(
map(to_string, res[i + fields_offset][::2]),
map(to_string, res[i + fields_offset][1::2]),
)
Expand Down Expand Up @@ -1633,7 +1633,7 @@ def schema_for_type(
parent_type=typ,
)
)
return " ".join(filter(None, sub_fields))
return " ".join([sub_field for sub_field in sub_fields if sub_field])
# NOTE: This is the termination point for recursion. We've descended
# into models and lists until we found an actual value to index.
elif should_index:
Expand Down
10 changes: 4 additions & 6 deletions aredis_om/model/render_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def render_tree(

if up is not None:
next_last = "up"
next_indent = "{0}{1}{2}".format(
indent, " " if "up" in last else "|", " " * len(str(name(current_node)))
)
next_indent = f'{indent}{" " if "up" in last else "|"}{" " * len(str(name(current_node)))}'
render_tree(
up, nameattr, left_child, right_child, next_indent, next_last, buffer
)
Expand All @@ -59,14 +57,14 @@ def render_tree(
end_shape = ""

print(
"{0}{1}{2}{3}".format(indent, start_shape, name(current_node), end_shape),
f"{indent}{start_shape}{name(current_node)}{end_shape}",
file=buffer,
)

if down is not None:
next_last = "down"
next_indent = "{0}{1}{2}".format(
indent, " " if "down" in last else "|", " " * len(str(name(current_node)))
next_indent = (
f'{indent}{" " if "down" in last else "|"}{len(str(name(current_node)))}'
)
render_tree(
down, nameattr, left_child, right_child, next_indent, next_last, buffer
Expand Down
2 changes: 1 addition & 1 deletion tests/test_oss_redis_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async def members(m):
async def test_all_keys(members, m):
pks = sorted([pk async for pk in await m.Member.all_pks()])
assert len(pks) == 3
assert pks == sorted([m.pk for m in members])
assert pks == sorted(m.pk for m in members)


@py_test_mark_asyncio
Expand Down

0 comments on commit 9ec9e83

Please sign in to comment.