コード例 #1
0
 def visit_With(self, node):
   for item in node.items:
     if item.optional_vars is not None:
       ast_util.apply_to_single_assignments((item.optional_vars,),
                                            item.context_expr,
                                            self._process_variable_assignment)
   self.generic_visit(node)
   return node
コード例 #2
0
 def test_apply_to_single_assignments_static_unpack(self):
   node = parser.parse_str('a, b, c = d, e, f')
   node = node.body[0]
   ast_util.apply_to_single_assignments(node.targets, node.value,
                                        self._mock_apply_fn)
   self.assertDictEqual(self._invocation_counts, {
       ('a', 'd'): 1,
       ('b', 'e'): 1,
       ('c', 'f'): 1,
   })
コード例 #3
0
 def test_apply_to_single_assignments_static_unpack(self):
     node = parser.parse_str('a, b, c = d, e, f')
     node = node.body[0]
     ast_util.apply_to_single_assignments(node.targets, node.value,
                                          self._mock_apply_fn)
     self.assertDictEqual(self._invocation_counts, {
         ('a', 'd'): 1,
         ('b', 'e'): 1,
         ('c', 'f'): 1,
     })
コード例 #4
0
 def visit_Assign(self, node):
   self.generic_visit(node)
   ast_util.apply_to_single_assignments(node.targets, node.value,
                                        self._process_variable_assignment)
   return node