diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index 86c971f16ca4..55fe5225947d 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -1679,7 +1679,7 @@ export function createTypeEvaluator( updatedFlags &= ~EvalFlags.TypeFormArg; - if (node.d.annotation) { + if (node.d.annotation && (flags & EvalFlags.TypeExpression) !== 0) { return getTypeOfExpression(node.d.annotation, updatedFlags); }