Beispiel #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
Beispiel #2
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
Beispiel #3
0
 def test_apply_to_single_assignments_static_unpack(self):
     node = parser.parse('a, b, c = d, e, f')
     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,
     })
Beispiel #4
0
 def test_apply_to_single_assignments_dynamic_unpack(self):
   node = parser.parse_str('a, b, c = d')
   ast_util.apply_to_single_assignments(node.targets, node.value,
                                        self._mock_apply_fn)
   self.assertDictEqual(self._invocation_counts, {
       ('a', 'd[0]'): 1,
       ('b', 'd[1]'): 1,
       ('c', 'd[2]'): 1,
   })
Beispiel #5
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,
   })
Beispiel #6
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
Beispiel #7
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