Skip to content

Commit

Permalink
fix: ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgrittner committed Sep 22, 2024
1 parent effdb6a commit 9ee8278
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions admyral/editor/json_with_references_serde.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ def deserialize_json_with_reference(value: str) -> JsonValue:
return None

# handle string escaping for ints, floats, bools, dicts, and lists
if (
value.startswith('"')
and value.endswith('"')
):
if value.startswith('"') and value.endswith('"'):
return value[1:-1]

# Handle pure reference
Expand Down Expand Up @@ -190,13 +187,17 @@ def deserialize_json_with_reference(value: str) -> JsonValue:
if is_within_string[start]:
# Already within a quote, however, we must still replace "
replacements.append(
(start, end, match.group().replace('\\"', '\"').replace('\"', '\\"'))
(start, end, match.group().replace('\\"', '"').replace('"', '\\"'))
)
else:
# We need to wrap the reference within quotes because it is currently not
# within quotes
replacements.append(
(start, end, f'"{match.group().replace('\\"', '\"').replace('\"', '\\"')}"')
(
start,
end,
f'"{match.group().replace('\\"', '\"').replace('\"', '\\"')}"',
)
)

# Wrap references into qutoes which are not yet within quotes
Expand Down
2 changes: 1 addition & 1 deletion tests/workers/test_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_list_with_references():
]


#########################################################################################################
#########################################################################################################


def test_key_with_list():
Expand Down

0 comments on commit 9ee8278

Please sign in to comment.