-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
IPython mode: load cell magics from configuration #13977
Comments
This seems like a reasonable request to me. Unlike I'd prefer to have an alternate option name like |
I'm also not sure if ruff handles it, but cell magics can be arbitrarily nested because the code-running cell magics (many of them anyway) call run_cell, which in turn may call cell magics, etc.. This is a valid cell containing Python code that should be recognized as a candidate for Python formatting assuming
whereas this one should not format the contents, since
|
I think we should handle it correctly because we check if any of the lines contains a cell magic which might not have valid Python code: ruff/crates/ruff_notebook/src/cell.rs Lines 206 to 207 in bd0d782
So, the two cells that you've provided works fine. |
In handling IPython magics, the list of magics that contain Python code to be checked/formatted is currently hard-coded.
Since loads of extensions (especially profiling, etc.) and even users can define these magics interactively, it seems like the list of cell magics that should be treated as containing Python code should be loaded from configuration, so users can lint their notebooks without a patch to ruff itself.
nbqa has this feature and can be used to run ruff on the contents of arbitrary cell magics, with the same default of assuming unrecognized cell magics don't contain Python code. A similar feature in ruff itself would be great!
Example notebook with the cells:
The text was updated successfully, but these errors were encountered: