From 10045a269d05acfe7b19d978a505d85d1495ff95 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 15 Jan 2025 13:09:24 -0800 Subject: [PATCH] Changed the fallback type from Unbound to Unknown for the case where pyright determines that a symbol requires code flow analysis but the execution scope exceeds the cyclomatic complexity threshold. This partly addresses #9709. --- packages/pyright-internal/src/analyzer/typeEvaluator.ts | 7 ++++++- packages/pyright-internal/src/common/fullAccessHost.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index 7d65022e41f2..594f9b3883f6 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -20712,7 +20712,12 @@ export function createTypeEvaluator( } if (checkCodeFlowTooComplex(reference)) { - return FlowNodeTypeResult.create(/* type */ undefined, /* isIncomplete */ true); + return FlowNodeTypeResult.create( + /* type */ options?.typeAtStart && isUnbound(options.typeAtStart.type) + ? UnknownType.create() + : undefined, + /* isIncomplete */ true + ); } // Is there an code flow analyzer cached for this execution scope? diff --git a/packages/pyright-internal/src/common/fullAccessHost.ts b/packages/pyright-internal/src/common/fullAccessHost.ts index f8c9da3cde7b..b2b588fc9e21 100644 --- a/packages/pyright-internal/src/common/fullAccessHost.ts +++ b/packages/pyright-internal/src/common/fullAccessHost.ts @@ -235,7 +235,7 @@ export class FullAccessHost extends LimitedAccessHost { } /** - * Excecutes a chunk of Python code via the provided interpreter and returns the output. + * Executes a chunk of Python code via the provided interpreter and returns the output. * @param interpreterPath Path to interpreter. * @param commandLineArgs Command line args for interpreter other than the code to execute. * @param code Code to execute.