Skip to content

Commit

Permalink
Prettify list encoding
Browse files Browse the repository at this point in the history
More closely match official TOML examples for lists by excluding
trailing commas.
  • Loading branch information
jcbrockschmidt committed Jan 20, 2021
1 parent 3f637db commit 99d17a2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions toml/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,9 @@ def get_empty_table(self):
return self._dict()

def dump_list(self, v):
retval = "["
for u in v:
retval += " " + unicode(self.dump_value(u)) + ","
retval += "]"
retval = "[ "
retval += ", ".join(unicode(self.dump_value(u)) for u in v)
retval += " ]"
return retval

def dump_inline_table(self, section):
Expand Down

0 comments on commit 99d17a2

Please sign in to comment.