Reformatted list (#5919)

* Reformatted list

* [autofix.ci] apply automated fixes

* Reformatted list

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Pradyot Ranjan 2023-02-09 16:08:27 +05:30 committed by GitHub
parent 8f78052493
commit 41555edab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 5 deletions

View file

@ -64,11 +64,11 @@ def format_msgpack(
elif type(data) is list:
output[-1] += [("text", "[")]
for item in data:
for count, item in enumerate(data):
output.append([indent, ("text", " ")])
format_msgpack(item, output, indent_count + 1)
if item != data[-1]:
if count != len(data) - 1:
output[-1] += [("text", ",")]
output.append([indent, ("text", "]")])

View file

@ -57,7 +57,9 @@ def test_format_msgpack():
[("text", ""), ("text", "}")],
]
assert list(msgpack.format_msgpack({"object": {"key": "value"}, "list": [1]})) == [
assert list(
msgpack.format_msgpack({"object": {"key": "value"}, "list": [0, 0, 1, 0, 0]})
) == [
[("text", "{")],
[
("text", ""),
@ -81,7 +83,31 @@ def test_format_msgpack():
("text", ": "),
("text", "["),
],
[("text", " "), ("text", " "), ("Token_Literal_Number", "1")],
[
("text", " "),
("text", " "),
("Token_Literal_Number", "0"),
("text", ","),
],
[
("text", " "),
("text", " "),
("Token_Literal_Number", "0"),
("text", ","),
],
[
("text", " "),
("text", " "),
("Token_Literal_Number", "1"),
("text", ","),
],
[
("text", " "),
("text", " "),
("Token_Literal_Number", "0"),
("text", ","),
],
[("text", " "), ("text", " "), ("Token_Literal_Number", "0")],
[("text", " "), ("text", "]")],
[("text", ""), ("text", "}")],
]