From 77e8da7497efdeff7e6cc2180d8818c62c5d8ef5 Mon Sep 17 00:00:00 2001 From: David Peter Date: Wed, 13 Nov 2024 20:58:08 +0100 Subject: [PATCH] [red-knot] Avoid panics for ipython magic commands (#14326) ## Summary Avoids panics when encountering Jupyter notebooks with [IPython magic commands](https://ipython.readthedocs.io/en/stable/interactive/magics.html). ## Test Plan Added Jupyter notebook to corpus. --- crates/red_knot_python_semantic/src/types/infer.rs | 5 ++++- .../test/corpus/83_jupyter_notebook_ipython_magic.ipynb | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 120000 crates/red_knot_workspace/resources/test/corpus/83_jupyter_notebook_ipython_magic.ipynb diff --git a/crates/red_knot_python_semantic/src/types/infer.rs b/crates/red_knot_python_semantic/src/types/infer.rs index 5801da5519..34bb0f915c 100644 --- a/crates/red_knot_python_semantic/src/types/infer.rs +++ b/crates/red_knot_python_semantic/src/types/infer.rs @@ -2164,7 +2164,10 @@ impl<'db> TypeInferenceBuilder<'db> { ast::Expr::Yield(yield_expression) => self.infer_yield_expression(yield_expression), ast::Expr::YieldFrom(yield_from) => self.infer_yield_from_expression(yield_from), ast::Expr::Await(await_expression) => self.infer_await_expression(await_expression), - ast::Expr::IpyEscapeCommand(_) => todo!("Implement Ipy escape command support"), + ast::Expr::IpyEscapeCommand(_) => { + // TODO Implement Ipy escape command support + Type::Todo + } }; self.store_expression_type(expression, ty); diff --git a/crates/red_knot_workspace/resources/test/corpus/83_jupyter_notebook_ipython_magic.ipynb b/crates/red_knot_workspace/resources/test/corpus/83_jupyter_notebook_ipython_magic.ipynb new file mode 120000 index 0000000000..82df885aaa --- /dev/null +++ b/crates/red_knot_workspace/resources/test/corpus/83_jupyter_notebook_ipython_magic.ipynb @@ -0,0 +1 @@ +../../../../ruff_notebook/resources/test/fixtures/jupyter/unused_variable.ipynb \ No newline at end of file