[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.
This commit is contained in:
David Peter 2024-11-13 20:58:08 +01:00 committed by GitHub
parent 5e64863895
commit 77e8da7497
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -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);

View file

@ -0,0 +1 @@
../../../../ruff_notebook/resources/test/fixtures/jupyter/unused_variable.ipynb