Skip to content

Commit

Permalink
New AST nodes todo!()
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Jul 24, 2023
1 parent e711a9f commit 59244ee
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/ruff_python_ast/src/comparable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
upper: upper.as_ref().map(Into::into),
step: step.as_ref().map(Into::into),
}),
ast::Expr::LineMagic(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -1449,6 +1450,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> {
ast::Stmt::Pass(_) => Self::Pass,
ast::Stmt::Break(_) => Self::Break,
ast::Stmt::Continue(_) => Self::Continue,
ast::Stmt::LineMagic(_) => todo!(),
}
}
}
2 changes: 2 additions & 0 deletions crates/ruff_python_ast/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ where
.map_or(false, |value| any_over_expr(value, func))
}
Expr::Name(_) | Expr::Constant(_) => false,
Expr::LineMagic(_) => todo!(),
}
}

Expand Down Expand Up @@ -565,6 +566,7 @@ where
range: _range,
}) => any_over_expr(value, func),
Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) => false,
Stmt::LineMagic(_) => todo!(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/ruff_python_ast/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,7 @@ impl From<Stmt> for AnyNode {
Stmt::Pass(node) => AnyNode::StmtPass(node),
Stmt::Break(node) => AnyNode::StmtBreak(node),
Stmt::Continue(node) => AnyNode::StmtContinue(node),
Stmt::LineMagic(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -3007,6 +3008,7 @@ impl From<Expr> for AnyNode {
Expr::List(node) => AnyNode::ExprList(node),
Expr::Tuple(node) => AnyNode::ExprTuple(node),
Expr::Slice(node) => AnyNode::ExprSlice(node),
Expr::LineMagic(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -4849,6 +4851,7 @@ impl<'a> From<&'a Stmt> for AnyNodeRef<'a> {
Stmt::Pass(node) => AnyNodeRef::StmtPass(node),
Stmt::Break(node) => AnyNodeRef::StmtBreak(node),
Stmt::Continue(node) => AnyNodeRef::StmtContinue(node),
Stmt::LineMagic(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -4883,6 +4886,7 @@ impl<'a> From<&'a Expr> for AnyNodeRef<'a> {
Expr::List(node) => AnyNodeRef::ExprList(node),
Expr::Tuple(node) => AnyNodeRef::ExprTuple(node),
Expr::Slice(node) => AnyNodeRef::ExprSlice(node),
Expr::LineMagic(_) => todo!(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_python_ast/src/relocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,6 @@ pub fn relocate_expr(expr: &mut Expr, location: TextRange) {
relocate_expr(expr, location);
}
}
Expr::LineMagic(_) => todo!(),
}
}
2 changes: 2 additions & 0 deletions crates/ruff_python_ast/src/source_code/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ impl<'a> Generator<'a> {
self.p("continue");
});
}
Stmt::LineMagic(_) => todo!(),
}
}

Expand Down Expand Up @@ -1270,6 +1271,7 @@ impl<'a> Generator<'a> {
self.unparse_expr(step, precedence::SLICE);
}
}
Expr::LineMagic(_) => todo!(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_python_ast/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ pub fn walk_stmt<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, stmt: &'a Stmt) {
}) => visitor.visit_expr(value),
Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) => {}
Stmt::TypeAlias(_) => todo!(),
Stmt::LineMagic(_) => todo!(),
}
}

Expand Down Expand Up @@ -586,6 +587,7 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
visitor.visit_expr(expr);
}
}
Expr::LineMagic(_) => todo!(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/ruff_python_ast/src/visitor/preorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ where
| Stmt::Global(_)
| Stmt::Nonlocal(_) => {}
Stmt::TypeAlias(_) => todo!(),
Stmt::LineMagic(_) => todo!(),
}
}

Expand Down Expand Up @@ -695,6 +696,7 @@ where
visitor.visit_expr(expr);
}
}
Expr::LineMagic(_) => todo!(),
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/ruff_python_formatter/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl FormatRule<Expr, PyFormatContext<'_>> for FormatExpr {
.with_options(TupleParentheses::Expr(parentheses))
.fmt(f),
Expr::Slice(expr) => expr.format().fmt(f),
Expr::LineMagic(_) => todo!(),
});

let parenthesize = match parentheses {
Expand Down Expand Up @@ -236,6 +237,7 @@ impl NeedsParentheses for Expr {
Expr::List(expr) => expr.needs_parentheses(parent, context),
Expr::Tuple(expr) => expr.needs_parentheses(parent, context),
Expr::Slice(expr) => expr.needs_parentheses(parent, context),
Expr::LineMagic(_) => todo!(),
}
}
}
Expand Down Expand Up @@ -408,6 +410,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
| Expr::Starred(_)
| Expr::Name(_)
| Expr::Slice(_) => {}
Expr::LineMagic(_) => todo!(),
};

walk_expr(self, expr);
Expand Down
1 change: 1 addition & 0 deletions crates/ruff_python_formatter/src/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl FormatRule<Stmt, PyFormatContext<'_>> for FormatStmt {
Stmt::Break(x) => x.format().fmt(f),
Stmt::Continue(x) => x.format().fmt(f),
Stmt::TypeAlias(x) => x.format().fmt(f),
Stmt::LineMagic(_) => todo!(),
}
}
}
Expand Down

0 comments on commit 59244ee

Please sign in to comment.