mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Integrate the new Jupyter AST nodes in Ruff (#6086)
## Summary This PR adds the implementation for the new Jupyter AST nodes i.e., `ExprLineMagic` and `StmtLineMagic`. ## Test Plan Add test cases for `unparse` containing magic commands resolves: #6087
This commit is contained in:
parent
1fdadee59c
commit
025fa4eba8
14 changed files with 228 additions and 19 deletions
|
@ -92,6 +92,7 @@ impl FormatRule<Expr, PyFormatContext<'_>> for FormatExpr {
|
|||
Expr::List(expr) => expr.format().fmt(f),
|
||||
Expr::Tuple(expr) => expr.format().fmt(f),
|
||||
Expr::Slice(expr) => expr.format().fmt(f),
|
||||
Expr::LineMagic(_) => todo!(),
|
||||
});
|
||||
|
||||
let parenthesize = match parentheses {
|
||||
|
@ -233,6 +234,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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -405,6 +407,7 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
|
|||
| Expr::Starred(_)
|
||||
| Expr::Name(_)
|
||||
| Expr::Slice(_) => {}
|
||||
Expr::LineMagic(_) => todo!(),
|
||||
};
|
||||
|
||||
walk_expr(self, expr);
|
||||
|
|
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue