Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate the new Jupyter AST nodes in Ruff #6086

Merged
merged 7 commits into from
Jul 26, 2023
Merged

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 26, 2023

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

@dhruvmanila
Copy link
Member Author

dhruvmanila commented Jul 26, 2023

@@ -671,11 +671,13 @@ impl<'stmt> BasicBlocksBuilder<'stmt> {
| Expr::Await(_)
| Expr::Yield(_)
| Expr::YieldFrom(_) => self.unconditional_next_block(after),
Expr::LineMagic(_) => todo!(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unreachable rule is under development, so I've left them as it is for now.

@@ -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!(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update the formatter todo!() later.

crates/ruff_python_ast/src/visitor.rs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Jul 26, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.03      9.7±0.06ms     4.2 MB/sec    1.00      9.4±0.08ms     4.3 MB/sec
formatter/numpy/ctypeslib.py               1.03   1927.4±7.90µs     8.6 MB/sec    1.00  1874.3±15.51µs     8.9 MB/sec
formatter/numpy/globals.py                 1.02    213.8±0.34µs    13.8 MB/sec    1.00    209.3±0.43µs    14.1 MB/sec
formatter/pydantic/types.py                1.03      4.1±0.01ms     6.2 MB/sec    1.00      4.0±0.02ms     6.3 MB/sec
linter/all-rules/large/dataset.py          1.00     12.9±0.12ms     3.2 MB/sec    1.00     12.8±0.11ms     3.2 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.2±0.02ms     5.2 MB/sec    1.00      3.2±0.02ms     5.2 MB/sec
linter/all-rules/numpy/globals.py          1.01    424.1±0.65µs     7.0 MB/sec    1.00    420.9±1.52µs     7.0 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.8±0.04ms     4.4 MB/sec    1.01      5.9±0.08ms     4.4 MB/sec
linter/default-rules/large/dataset.py      1.01      6.7±0.04ms     6.1 MB/sec    1.00      6.6±0.04ms     6.2 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.01   1416.2±3.15µs    11.8 MB/sec    1.00   1404.6±4.37µs    11.9 MB/sec
linter/default-rules/numpy/globals.py      1.00    158.2±0.59µs    18.6 MB/sec    1.00    158.3±0.87µs    18.6 MB/sec
linter/default-rules/pydantic/types.py     1.01      3.0±0.01ms     8.4 MB/sec    1.00      3.0±0.01ms     8.6 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00     11.8±0.67ms     3.4 MB/sec    1.02     12.0±0.63ms     3.4 MB/sec
formatter/numpy/ctypeslib.py               1.00      2.4±0.11ms     7.1 MB/sec    1.04      2.4±0.13ms     6.8 MB/sec
formatter/numpy/globals.py                 1.05   278.0±17.00µs    10.6 MB/sec    1.00   263.7±22.24µs    11.2 MB/sec
formatter/pydantic/types.py                1.00      5.0±0.27ms     5.1 MB/sec    1.06      5.3±0.27ms     4.8 MB/sec
linter/all-rules/large/dataset.py          1.00     16.2±0.79ms     2.5 MB/sec    1.04     16.8±0.81ms     2.4 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      4.4±0.17ms     3.8 MB/sec    1.00      4.3±0.27ms     3.9 MB/sec
linter/all-rules/numpy/globals.py          1.03   543.7±30.35µs     5.4 MB/sec    1.00   526.0±24.56µs     5.6 MB/sec
linter/all-rules/pydantic/types.py         1.03      7.8±0.34ms     3.3 MB/sec    1.00      7.6±0.44ms     3.4 MB/sec
linter/default-rules/large/dataset.py      1.06      9.5±0.71ms     4.3 MB/sec    1.00      9.0±0.40ms     4.5 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1867.0±97.67µs     8.9 MB/sec    1.00  1867.3±96.26µs     8.9 MB/sec
linter/default-rules/numpy/globals.py      1.01   234.1±14.26µs    12.6 MB/sec    1.00   232.2±11.20µs    12.7 MB/sec
linter/default-rules/pydantic/types.py     1.00      4.0±0.21ms     6.4 MB/sec    1.04      4.1±0.24ms     6.1 MB/sec

@dhruvmanila dhruvmanila enabled auto-merge (squash) July 26, 2023 08:07
@dhruvmanila dhruvmanila merged commit 025fa4e into main Jul 26, 2023
16 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/jupyter-ast-impl branch July 26, 2023 08:20
@dhruvmanila dhruvmanila added the internal An internal refactor or improvement label Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add required changes for handling the new Jupyter AST nodes
2 participants