Example #1
0
 def visit_with_stmt(self, node: WithStmt) -> WithStmt:
     new = WithStmt(self.expressions(node.expr),
                    self.optional_expressions(node.target),
                    self.block(node.body),
                    self.optional_type(node.unanalyzed_type))
     new.analyzed_types = [self.type(typ) for typ in node.analyzed_types]
     return new
Example #2
0
 def visit_AsyncWith(self, n: ast3.AsyncWith) -> WithStmt:
     if n.type_comment is not None:
         target_type = parse_type_comment(n.type_comment, n.lineno,
                                          self.errors)
     else:
         target_type = None
     r = WithStmt([self.visit(i.context_expr) for i in n.items],
                  [self.visit(i.optional_vars) for i in n.items],
                  self.as_block(n.body, n.lineno), target_type)
     r.is_async = True
     return r
Example #3
0
 def visit_AsyncWith(self, n: ast3.AsyncWith) -> WithStmt:
     if n.type_comment is not None:
         target_type = parse_type_comment(n.type_comment, n.lineno, self.errors)
     else:
         target_type = None
     r = WithStmt([self.visit(i.context_expr) for i in n.items],
                  [self.visit(i.optional_vars) for i in n.items],
                  self.as_required_block(n.body, n.lineno),
                  target_type)
     r.is_async = True
     return r
Example #4
0
 def visit_With(self, n: ast27.With) -> WithStmt:
     typ = self.translate_type_comment(n, n.type_comment)
     stmt = WithStmt([self.visit(n.context_expr)],
                     [self.visit(n.optional_vars)],
                     self.as_required_block(n.body, n.lineno),
                     typ)
     return self.set_line(stmt, n)
Example #5
0
 def visit_With(self, n: ast27.With) -> WithStmt:
     if n.type_comment is not None:
         target_type = parse_type_comment(n.type_comment, n.lineno, self.errors)
     else:
         target_type = None
     return WithStmt([self.visit(n.context_expr)],
                     [self.visit(n.optional_vars)],
                     self.as_required_block(n.body, n.lineno),
                     target_type)
Example #6
0
 def visit_With(self, n: ast3.With) -> WithStmt:
     if n.type_comment is not None:
         target_type = parse_type_comment(n.type_comment, n.lineno,
                                          self.errors)
     else:
         target_type = None
     node = WithStmt([self.visit(i.context_expr) for i in n.items],
                     [self.visit(i.optional_vars) for i in n.items],
                     self.as_required_block(n.body, n.lineno), target_type)
     return self.set_line(node, n)
Example #7
0
 def visit_With(self, n: ast27.With) -> WithStmt:
     if n.type_comment is not None:
         target_type = parse_type_comment(n.type_comment, n.lineno, self.errors,
                                          assume_str_is_unicode=self.unicode_literals)
     else:
         target_type = None
     stmt = WithStmt([self.visit(n.context_expr)],
                     [self.visit(n.optional_vars)],
                     self.as_required_block(n.body, n.lineno),
                     target_type)
     return self.set_line(stmt, n)
Example #8
0
 def visit_With(self, n: ast27.With) -> WithStmt:
     if n.type_comment is not None:
         extra_ignore, typ = parse_type_comment(n.type_comment,
                                                n.lineno,
                                                n.col_offset,
                                                self.errors,
                                                assume_str_is_unicode=self.unicode_literals)
         if extra_ignore:
             self.type_ignores.add(n.lineno)
     else:
         typ = None
     stmt = WithStmt([self.visit(n.context_expr)],
                     [self.visit(n.optional_vars)],
                     self.as_required_block(n.body, n.lineno),
                     typ)
     return self.set_line(stmt, n)
Example #9
0
 def visit_With(self, n: ast35.With) -> Node:
     return WithStmt([self.visit(i.context_expr) for i in n.items],
                     [self.visit(i.optional_vars) for i in n.items],
                     self.as_block(n.body, n.lineno))
Example #10
0
 def visit_with_stmt(self, node: WithStmt) -> Node:
     return WithStmt(self.nodes(node.expr), self.optional_names(node.name),
                     self.block(node.body))
Example #11
0
 def visit_With(self, n: ast27.With) -> WithStmt:
     return WithStmt([self.visit(n.context_expr)],
                     [self.visit(n.optional_vars)],
                     self.as_block(n.body, n.lineno))
Example #12
0
 def visit_AsyncWith(self, n: ast35.AsyncWith) -> WithStmt:
     r = WithStmt([self.visit(i.context_expr) for i in n.items],
                  [self.visit(i.optional_vars) for i in n.items],
                  self.as_block(n.body, n.lineno))
     r.is_async = True
     return r
Example #13
0
 def visit_with_stmt(self, node: WithStmt) -> WithStmt:
     return WithStmt(self.expressions(node.expr),
                     self.optional_expressions(node.target),
                     self.block(node.body),
                     self.optional_type(node.target_type))
Example #14
0
 def visit_AsyncWith(self, n: ast35.AsyncWith) -> Node:
     r = WithStmt([self.visit(i.context_expr) for i in n.items],
                  [self.visit(i.optional_vars) for i in n.items],
                  self.as_block(n.body, n.lineno))
     r.is_async = True
     return r
Example #15
0
 def visit_with_stmt(self, node: WithStmt) -> None:
     super().visit_with_stmt(node)
     node.analyzed_types = []
Example #16
0
 def visit_with_stmt(self, node: WithStmt) -> None:
     super().visit_with_stmt(node)
     node.analyzed_types = []