From bbdfde856b8c20fa3def98ea4610fef02aa316d7 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 25 Oct 2024 14:32:33 -0700 Subject: [PATCH] Changed the evaluated type of an `in` or `not in` operator to be `bool` if the LHS doesn't support containment. Previously, the expression evaluated to `Never`. This addresses #9327. --- packages/pyright-internal/src/analyzer/operations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pyright-internal/src/analyzer/operations.ts b/packages/pyright-internal/src/analyzer/operations.ts index fceccba4a455..d71c582b19d7 100644 --- a/packages/pyright-internal/src/analyzer/operations.ts +++ b/packages/pyright-internal/src/analyzer/operations.ts @@ -1198,7 +1198,7 @@ function validateContainmentOperation( deprecatedInfo = returnTypeResult.magicMethodDeprecationInfo; } - return returnTypeResult?.type; + return returnTypeResult?.type ?? evaluator.getBuiltInObject(errorNode, 'bool'); } ); }