mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Allow transparent cell magics (#8911)
## Summary This PR updates the logic for `is_magic_cell` to include certain cell magics. These cell magics would contain Python code following the line defining the command. The code could define a variable which can then be referenced in other cells. Currently, we would ignore the cell completely leading to undefined-name violation. As discussed in https://github.com/astral-sh/ruff/issues/8354#issuecomment-1832221009 ## Test Plan Add new test case to validate this scenario.
This commit is contained in:
parent
04ec11a73d
commit
6bbabceead
7 changed files with 102 additions and 4 deletions
|
@ -19,5 +19,20 @@ ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused
|
|||
5 |-import os
|
||||
6 5 |
|
||||
7 6 | _ = math.pi
|
||||
8 7 | %%timeit
|
||||
|
||||
ipy_escape_command.ipynb:cell 2:2:8: F401 [*] `sys` imported but unused
|
||||
|
|
||||
1 | %%timeit
|
||||
2 | import sys
|
||||
| ^^^ F401
|
||||
|
|
||||
= help: Remove unused import: `sys`
|
||||
|
||||
ℹ Safe fix
|
||||
6 6 |
|
||||
7 7 | _ = math.pi
|
||||
8 8 | %%timeit
|
||||
9 |-import sys
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue