[ty] Revert "Do not infer types for invalid binary expressions in annotations" (#21914)

See discussion here:
https://github.com/astral-sh/ruff/pull/21911#discussion_r2610155157
This commit is contained in:
David Peter 2025-12-11 12:57:45 +01:00 committed by GitHub
parent aa27925e87
commit 71540c03b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -155,6 +155,12 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
}
// anything else is an invalid annotation:
op => {
// Avoid inferring the types of invalid binary expressions that have been
// parsed from a string annotation, as they are not present in the semantic
// index.
if !self.deferred_state.in_string_annotation() {
self.infer_binary_expression(binary, TypeContext::default());
}
self.report_invalid_type_expression(
expression,
format_args!(