From 5caabe54b63bf2688d03d8c770bef6c3c0ce783e Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Mon, 14 Oct 2024 15:48:33 +0530 Subject: [PATCH] Allow `ipytest` cell magic (#13745) ## Summary fixes: #13718 ## Test Plan Using the notebook as mentioned in https://github.com/astral-sh/ruff/issues/13718#issuecomment-2410631674, this PR does not give the "F821 Undefined name `test_sorted`" diagnostic. --- crates/ruff_notebook/src/cell.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/ruff_notebook/src/cell.rs b/crates/ruff_notebook/src/cell.rs index 1d7985e4a3..c917dd1627 100644 --- a/crates/ruff_notebook/src/cell.rs +++ b/crates/ruff_notebook/src/cell.rs @@ -238,9 +238,19 @@ impl Cell { // // This is to avoid false positives when these variables are referenced // elsewhere in the notebook. + // + // Refer https://github.com/astral-sh/ruff/issues/13718 for `ipytest`. !matches!( command, - "capture" | "debug" | "prun" | "pypy" | "python" | "python3" | "time" | "timeit" + "capture" + | "debug" + | "ipytest" + | "prun" + | "pypy" + | "python" + | "python3" + | "time" + | "timeit" ) }) }