nbQA
nbQA copied to clipboard
Cell magics starting with single '%' are not ignored
For better or worse, some systems use single '%' headers for cell magics, notably Databricks, e.g. %sql and %r.
I successfully used nbQA with %sql cells for a long time (they magically just get ignored), however, with %r cells, nbqa-ruff-check and nbqa-ruff-format has a false positive at the below example (in R, <- is the assignment operator):
nbqa-ruff-check..........................................................Failed
- hook id: nbqa-ruff-check
- exit code: 1
r\install sf.ipynb:cell_3:2:1: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
|
9 | # %%NBQA-CELL-SEPe5ddb4
10 | hash(0x96DAFA9D)
11 | var <- 1 + 1
| ^^^^^^^^^^^^ B015
|
Found 1 error.
nbqa-ruff-format.........................................................Failed
- hook id: nbqa-ruff-format
- files were modified by this hook
1 file reformatted
and the reformat is:
- "var <- 1 + 1"
+ "var < -1 + 1"
(if I use %%r, they are ignored -- but %r is the right cell magic in this env.)
I wonder if there's a way to work around this?