From 533d9093b22e8dba89059547dbef972d22fc288b Mon Sep 17 00:00:00 2001 From: David Peter Date: Thu, 11 Dec 2025 12:51:58 +0100 Subject: [PATCH] Revert "Do not infer types for invalid binary expressions in annotations" This reverts commit f2e50c4f83045fe6f5c2d433260ba97a66df6370. --- .../src/types/infer/builder/type_expression.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs index a3ffabe826..626225cdc8 100644 --- a/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs +++ b/crates/ty_python_semantic/src/types/infer/builder/type_expression.rs @@ -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!(