Skip to content

Commit

Permalink
Rename all instances of StmtLineMagic/ExprLineMagic
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Aug 9, 2023
1 parent 4999dff commit 9207a40
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions crates/ruff/src/jupyter/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,11 @@ print("after empty cells")
}

#[test]
fn test_line_magics() -> Result<()> {
let path = "line_magics.ipynb".to_string();
fn test_ipy_escape_command() -> Result<()> {
let path = "ipy_escape_command.ipynb".to_string();
let (diagnostics, source_kind, _) = test_notebook_path(
&path,
Path::new("line_magics_expected.ipynb"),
Path::new("ipy_escape_command_expected.ipynb"),
&settings::Settings::for_rule(Rule::UnusedImport),
)?;
assert_messages!(diagnostics, path, source_kind);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/ruff/src/jupyter/notebook.rs
---
line_magics.ipynb:cell 1:5:8: F401 [*] `os` imported but unused
ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused
|
3 | %matplotlib inline
4 |
Expand Down
12 changes: 6 additions & 6 deletions crates/ruff_python_ast/src/comparable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ pub struct ExprSlice<'a> {
}

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct ExprLineMagic<'a> {
pub struct ExprIpyEscapeCommand<'a> {
kind: ast::IpyEscapeKind,
value: &'a str,
}
Expand Down Expand Up @@ -706,7 +706,7 @@ pub enum ComparableExpr<'a> {
List(ExprList<'a>),
Tuple(ExprTuple<'a>),
Slice(ExprSlice<'a>),
LineMagic(ExprLineMagic<'a>),
IpyEscapeCommand(ExprIpyEscapeCommand<'a>),
}

impl<'a> From<&'a Box<ast::Expr>> for Box<ComparableExpr<'a>> {
Expand Down Expand Up @@ -940,7 +940,7 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
kind,
value,
range: _,
}) => Self::LineMagic(ExprLineMagic {
}) => Self::IpyEscapeCommand(ExprIpyEscapeCommand {
kind: *kind,
value: value.as_str(),
}),
Expand Down Expand Up @@ -1165,7 +1165,7 @@ pub struct StmtExpr<'a> {
}

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct StmtLineMagic<'a> {
pub struct StmtIpyEscapeCommand<'a> {
kind: ast::IpyEscapeKind,
value: &'a str,
}
Expand Down Expand Up @@ -1193,7 +1193,7 @@ pub enum ComparableStmt<'a> {
ImportFrom(StmtImportFrom<'a>),
Global(StmtGlobal<'a>),
Nonlocal(StmtNonlocal<'a>),
LineMagic(StmtLineMagic<'a>),
IpyEscapeCommand(StmtIpyEscapeCommand<'a>),
Expr(StmtExpr<'a>),
Pass,
Break,
Expand Down Expand Up @@ -1398,7 +1398,7 @@ impl<'a> From<&'a ast::Stmt> for ComparableStmt<'a> {
kind,
value,
range: _,
}) => Self::LineMagic(StmtLineMagic {
}) => Self::IpyEscapeCommand(StmtIpyEscapeCommand {
kind: *kind,
value: value.as_str(),
}),
Expand Down
Loading

0 comments on commit 9207a40

Please sign in to comment.