)
def visit_Tuple(self, node):
- with self.require_parens(_Precedence.TUPLE, node):
+ with self.delimit_if(
+ "(",
+ ")",
+ len(node.elts) == 0 or self.get_precedence(node) > _Precedence.TUPLE
+ ):
self.items_view(self.traverse, node.elts)
unop = {"Invert": "~", "Not": "not", "UAdd": "+", "USub": "-"}
self.check_src_roundtrip(source.format(target=target))
def test_star_expr_assign_target_multiple(self):
+ self.check_src_roundtrip("() = []")
+ self.check_src_roundtrip("[] = ()")
+ self.check_src_roundtrip("() = [a] = c, = [d] = e, f = () = g = h")
self.check_src_roundtrip("a = b = c = d")
self.check_src_roundtrip("a, b = c, d = e, f = g")
self.check_src_roundtrip("[a, b] = [c, d] = [e, f] = g")