Skip to content

Commit

Permalink
Fix the formatting in nested CompositeLit
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Mert Yildiran committed Feb 24, 2021
1 parent 4a9d9eb commit 1ca5353
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions gopygo/unparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ def basic_lit(self, node):

def composite_lit(self, node):
if node.elts:
return '%s{\n%s%s}' % (
getattr(self, _get_node_type(node.type))(node.type),
getattr(self, _get_node_type(node.elts))(
node.elts,
separator=',\n',
indent=((self.indent + 1) * INDENT)
),
self.indent * INDENT
text = '%s{\n' % getattr(self, _get_node_type(node.type))(node.type)
self.indent += 1
text += '%s' % getattr(self, _get_node_type(node.elts))(
node.elts,
separator=',\n',
indent=(self.indent * INDENT)
)
self.indent -= 1
text += '%s}' % (self.indent * INDENT)
return text
else:
return '%s{}' % getattr(self, _get_node_type(node.type))(node.type)

Expand Down

0 comments on commit 1ca5353

Please sign in to comment.