Skip to content

Commit

Permalink
Changed the fallback type from Unbound to Unknown for the case where …
Browse files Browse the repository at this point in the history
…pyright determines that a symbol requires code flow analysis but the execution scope exceeds the cyclomatic complexity threshold. This partly addresses #9709.
  • Loading branch information
erictraut committed Jan 15, 2025
1 parent 2b126fa commit 10045a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/common/fullAccessHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 10045a2

Please sign in to comment.