Formatter: Add trailing commas in lists

This commit is contained in:
Alexey Yerin 2025-01-04 10:20:54 +03:00 committed by James Westman
parent 55e5095fba
commit b9f58aeab5
7 changed files with 59 additions and 4 deletions

View file

@ -146,8 +146,10 @@ def format(data, tab_size=2, insert_space=True):
is_child_type = False
elif str_item in CLOSING_TOKENS:
if str_item == "]" and last_not_whitespace != ",":
if str_item == "]" and str(last_not_whitespace) != "[":
current_line = current_line[:-1]
if str(last_not_whitespace) != ",":
current_line += ","
commit_current_line()
current_line = "]"
elif str(last_not_whitespace) in OPENING_TOKENS: