Skip to content

Commit

Permalink
[red-knot] Add Type::Todo to expression types for string annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Nov 4, 2024
1 parent 5fb8ca7 commit 0df668c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 1 addition & 6 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ fn definition_expression_ty<'db>(
if let Some(ty) = inference.try_expression_ty(expr_id) {
ty
} else {
infer_deferred_types(db, definition)
.try_expression_ty(expr_id)
.unwrap_or(
// Some deferred cases like string annotations are not yet implemented
Type::Todo,
)
infer_deferred_types(db, definition).expression_ty(expr_id)
}
}

Expand Down
5 changes: 4 additions & 1 deletion crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3655,7 +3655,10 @@ impl<'db> TypeInferenceBuilder<'db> {
// TODO: parse the expression and check whether it is a string annotation, since they
// can be annotation expressions distinct from type expressions.
// https://typing.readthedocs.io/en/latest/spec/annotations.html#string-annotations
ast::Expr::StringLiteral(_literal) => Type::Todo,
ast::Expr::StringLiteral(_literal) => {
self.store_expression_type(expression, Type::Todo);
Type::Todo
}

// Annotation expressions also get special handling for `*args` and `**kwargs`.
ast::Expr::Starred(starred) => self.infer_starred_expression(starred),
Expand Down

0 comments on commit 0df668c

Please sign in to comment.