Skip to content

Commit

Permalink
fixup! [red-knot] feat: implement and use repr/str for f-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Slyces committed Sep 26, 2024
1 parent daacaf7 commit 04ed1b5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ impl<'db> TypeInferenceBuilder<'db> {
format_spec,
} = expression;
// Always infer sub-expressions, even if we've figured out the type
let ty = self.infer_expression(&expression);
let ty = self.infer_expression(expression);
if !done {
// TODO: handle format specifiers by calling a method
// (`Type::format`?) that handles the `__format__` method.
Expand All @@ -1684,14 +1684,12 @@ impl<'db> TypeInferenceBuilder<'db> {
has_expression = true;
done = true;
} else {
match ty.str(self.db) {
Some(Type::StringLiteral(literal)) => {
concatenated.push_str(literal.value(self.db));
}
_ => {
has_expression = true;
done = true;
}
if let Some(Type::StringLiteral(literal)) = ty.str(self.db)
{
concatenated.push_str(literal.value(self.db));
} else {
has_expression = true;
done = true;
}
}
}
Expand Down

0 comments on commit 04ed1b5

Please sign in to comment.