Skip to content

Commit

Permalink
Rename Magic* to IpyEscape*
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Aug 9, 2023
1 parent e257c5a commit 4316c2a
Show file tree
Hide file tree
Showing 22 changed files with 818 additions and 815 deletions.
8 changes: 4 additions & 4 deletions crates/ruff/src/rules/ruff/rules/unreachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,13 @@ impl<'stmt> BasicBlocksBuilder<'stmt> {
| Expr::Await(_)
| Expr::Yield(_)
| Expr::YieldFrom(_) => self.unconditional_next_block(after),
Expr::LineMagic(_) => todo!(),
Expr::IpyEscapeCommand(_) => todo!(),
}
}
// The tough branches are done, here is an easy one.
Stmt::Return(_) => NextBlock::Terminate,
Stmt::TypeAlias(_) => todo!(),
Stmt::LineMagic(_) => todo!(),
Stmt::IpyEscapeCommand(_) => todo!(),
};

// Include any statements in the block that don't divert the control flow.
Expand Down Expand Up @@ -903,7 +903,7 @@ fn needs_next_block(stmts: &[Stmt]) -> bool {
| Stmt::TryStar(_)
| Stmt::Assert(_) => true,
Stmt::TypeAlias(_) => todo!(),
Stmt::LineMagic(_) => todo!(),
Stmt::IpyEscapeCommand(_) => todo!(),
}
}

Expand Down Expand Up @@ -936,7 +936,7 @@ fn is_control_flow_stmt(stmt: &Stmt) -> bool {
| Stmt::Break(_)
| Stmt::Continue(_) => true,
Stmt::TypeAlias(_) => todo!(),
Stmt::LineMagic(_) => todo!(),
Stmt::IpyEscapeCommand(_) => todo!(),
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/ruff_python_ast/src/comparable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ pub struct ExprSlice<'a> {

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ExprLineMagic<'a> {
kind: ast::MagicKind,
kind: ast::IpyEscapeKind,
value: &'a str,
}

Expand Down Expand Up @@ -936,7 +936,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(ast::ExprLineMagic {
ast::Expr::IpyEscapeCommand(ast::ExprIpyEscapeCommand {
kind,
value,
range: _,
Expand Down Expand Up @@ -1166,7 +1166,7 @@ pub struct StmtExpr<'a> {

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct StmtLineMagic<'a> {
kind: ast::MagicKind,
kind: ast::IpyEscapeKind,
value: &'a str,
}

Expand Down Expand Up @@ -1394,7 +1394,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> {
names: names.iter().map(ast::Identifier::as_str).collect(),
})
}
ast::Stmt::LineMagic(ast::StmtLineMagic {
ast::Stmt::IpyEscapeCommand(ast::StmtIpyEscapeCommand {
kind,
value,
range: _,
Expand Down
6 changes: 3 additions & 3 deletions crates/ruff_python_ast/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ where
| Expr::Subscript(_)
| Expr::Yield(_)
| Expr::YieldFrom(_)
| Expr::LineMagic(_)
| Expr::IpyEscapeCommand(_)
)
})
}
Expand Down Expand Up @@ -247,7 +247,7 @@ where
.is_some_and(|value| any_over_expr(value, func))
}
Expr::Name(_) | Expr::Constant(_) => false,
Expr::LineMagic(_) => false,
Expr::IpyEscapeCommand(_) => false,
}
}

Expand Down Expand Up @@ -534,7 +534,7 @@ where
Stmt::Nonlocal(_) => false,
Stmt::Expr(ast::StmtExpr { value, range: _ }) => any_over_expr(value, func),
Stmt::Pass(_) | Stmt::Break(_) | Stmt::Continue(_) => false,
Stmt::LineMagic(_) => false,
Stmt::IpyEscapeCommand(_) => false,
}
}

Expand Down
40 changes: 20 additions & 20 deletions crates/ruff_python_ast/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum AnyNode {
StmtPass(ast::StmtPass),
StmtBreak(ast::StmtBreak),
StmtContinue(ast::StmtContinue),
StmtLineMagic(ast::StmtLineMagic),
StmtLineMagic(ast::StmtIpyEscapeCommand),
ExprBoolOp(ast::ExprBoolOp),
ExprNamedExpr(ast::ExprNamedExpr),
ExprBinOp(ast::ExprBinOp),
Expand Down Expand Up @@ -76,7 +76,7 @@ pub enum AnyNode {
ExprList(ast::ExprList),
ExprTuple(ast::ExprTuple),
ExprSlice(ast::ExprSlice),
ExprLineMagic(ast::ExprLineMagic),
ExprLineMagic(ast::ExprIpyEscapeCommand),
ExceptHandlerExceptHandler(ast::ExceptHandlerExceptHandler),
PatternMatchValue(ast::PatternMatchValue),
PatternMatchSingleton(ast::PatternMatchSingleton),
Expand Down Expand Up @@ -131,7 +131,7 @@ impl AnyNode {
AnyNode::StmtPass(node) => Some(Stmt::Pass(node)),
AnyNode::StmtBreak(node) => Some(Stmt::Break(node)),
AnyNode::StmtContinue(node) => Some(Stmt::Continue(node)),
AnyNode::StmtLineMagic(node) => Some(Stmt::LineMagic(node)),
AnyNode::StmtLineMagic(node) => Some(Stmt::IpyEscapeCommand(node)),

AnyNode::ModModule(_)
| AnyNode::ModExpression(_)
Expand Down Expand Up @@ -219,7 +219,7 @@ impl AnyNode {
AnyNode::ExprList(node) => Some(Expr::List(node)),
AnyNode::ExprTuple(node) => Some(Expr::Tuple(node)),
AnyNode::ExprSlice(node) => Some(Expr::Slice(node)),
AnyNode::ExprLineMagic(node) => Some(Expr::LineMagic(node)),
AnyNode::ExprLineMagic(node) => Some(Expr::IpyEscapeCommand(node)),

AnyNode::ModModule(_)
| AnyNode::ModExpression(_)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ impl AstNode for ast::StmtContinue {
AnyNode::from(self)
}
}
impl AstNode for ast::StmtLineMagic {
impl AstNode for ast::StmtIpyEscapeCommand {
fn cast(kind: AnyNode) -> Option<Self>
where
Self: Sized,
Expand Down Expand Up @@ -2213,7 +2213,7 @@ impl AstNode for ast::ExprSlice {
AnyNode::from(self)
}
}
impl AstNode for ast::ExprLineMagic {
impl AstNode for ast::ExprIpyEscapeCommand {
fn cast(kind: AnyNode) -> Option<Self>
where
Self: Sized,
Expand Down Expand Up @@ -2915,7 +2915,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(node) => AnyNode::StmtLineMagic(node),
Stmt::IpyEscapeCommand(node) => AnyNode::StmtLineMagic(node),
}
}
}
Expand Down Expand Up @@ -2950,7 +2950,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(node) => AnyNode::ExprLineMagic(node),
Expr::IpyEscapeCommand(node) => AnyNode::ExprLineMagic(node),
}
}
}
Expand Down Expand Up @@ -3155,8 +3155,8 @@ impl From<ast::StmtContinue> for AnyNode {
}
}

impl From<ast::StmtLineMagic> for AnyNode {
fn from(node: ast::StmtLineMagic) -> Self {
impl From<ast::StmtIpyEscapeCommand> for AnyNode {
fn from(node: ast::StmtIpyEscapeCommand) -> Self {
AnyNode::StmtLineMagic(node)
}
}
Expand Down Expand Up @@ -3323,8 +3323,8 @@ impl From<ast::ExprSlice> for AnyNode {
}
}

impl From<ast::ExprLineMagic> for AnyNode {
fn from(node: ast::ExprLineMagic) -> Self {
impl From<ast::ExprIpyEscapeCommand> for AnyNode {
fn from(node: ast::ExprIpyEscapeCommand) -> Self {
AnyNode::ExprLineMagic(node)
}
}
Expand Down Expand Up @@ -3572,7 +3572,7 @@ pub enum AnyNodeRef<'a> {
StmtPass(&'a ast::StmtPass),
StmtBreak(&'a ast::StmtBreak),
StmtContinue(&'a ast::StmtContinue),
StmtLineMagic(&'a ast::StmtLineMagic),
StmtLineMagic(&'a ast::StmtIpyEscapeCommand),
ExprBoolOp(&'a ast::ExprBoolOp),
ExprNamedExpr(&'a ast::ExprNamedExpr),
ExprBinOp(&'a ast::ExprBinOp),
Expand Down Expand Up @@ -3600,7 +3600,7 @@ pub enum AnyNodeRef<'a> {
ExprList(&'a ast::ExprList),
ExprTuple(&'a ast::ExprTuple),
ExprSlice(&'a ast::ExprSlice),
ExprLineMagic(&'a ast::ExprLineMagic),
ExprLineMagic(&'a ast::ExprIpyEscapeCommand),
ExceptHandlerExceptHandler(&'a ast::ExceptHandlerExceptHandler),
PatternMatchValue(&'a ast::PatternMatchValue),
PatternMatchSingleton(&'a ast::PatternMatchSingleton),
Expand Down Expand Up @@ -4429,8 +4429,8 @@ impl<'a> From<&'a ast::StmtContinue> for AnyNodeRef<'a> {
}
}

impl<'a> From<&'a ast::StmtLineMagic> for AnyNodeRef<'a> {
fn from(node: &'a ast::StmtLineMagic) -> Self {
impl<'a> From<&'a ast::StmtIpyEscapeCommand> for AnyNodeRef<'a> {
fn from(node: &'a ast::StmtIpyEscapeCommand) -> Self {
AnyNodeRef::StmtLineMagic(node)
}
}
Expand Down Expand Up @@ -4597,8 +4597,8 @@ impl<'a> From<&'a ast::ExprSlice> for AnyNodeRef<'a> {
}
}

impl<'a> From<&'a ast::ExprLineMagic> for AnyNodeRef<'a> {
fn from(node: &'a ast::ExprLineMagic) -> Self {
impl<'a> From<&'a ast::ExprIpyEscapeCommand> for AnyNodeRef<'a> {
fn from(node: &'a ast::ExprIpyEscapeCommand) -> Self {
AnyNodeRef::ExprLineMagic(node)
}
}
Expand Down Expand Up @@ -4714,7 +4714,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(node) => AnyNodeRef::StmtLineMagic(node),
Stmt::IpyEscapeCommand(node) => AnyNodeRef::StmtLineMagic(node),
}
}
}
Expand Down Expand Up @@ -4749,7 +4749,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(node) => AnyNodeRef::ExprLineMagic(node),
Expr::IpyEscapeCommand(node) => AnyNodeRef::ExprLineMagic(node),
}
}
}
Expand Down
Loading

0 comments on commit 4316c2a

Please sign in to comment.