Skip to content

Commit

Permalink
[red-knot] visit with-item vars even if not a Name (#13409)
Browse files Browse the repository at this point in the history
This fixes the last panic on checking pandas.

(Match statement became an `if let` because clippy decided it wanted
that once I added the additional line in the else case?)

---------

Co-authored-by: Alex Waygood <[email protected]>
  • Loading branch information
carljm and AlexWaygood authored Sep 19, 2024
1 parent f110d80 commit 260c2ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 7 additions & 8 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,14 +926,13 @@ impl<'db> TypeInferenceBuilder<'db> {
} = with_statement;

for item in items {
match item.optional_vars.as_deref() {
Some(ast::Expr::Name(name)) => {
self.infer_definition(name);
}
_ => {
// TODO infer definitions in unpacking assignment
self.infer_expression(&item.context_expr);
}
let target = item.optional_vars.as_deref();
if let Some(ast::Expr::Name(name)) = target {
self.infer_definition(name);
} else {
// TODO infer definitions in unpacking assignment
self.infer_expression(&item.context_expr);
self.infer_optional_expression(target);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
with foo() as self.bar:
pass

0 comments on commit 260c2ec

Please sign in to comment.