Skip to content

Commit 722376c

Browse files
authored
Tweaked the algorithm for computing the complexity of a code flow graph to accommodate slightly larger graphs before giving up. This addresses #9778. (#9781)
1 parent 7f60dc7 commit 722376c

File tree

1 file changed

+19
-11
lines changed
  • packages/pyright-internal/src/analyzer

1 file changed

+19
-11
lines changed

packages/pyright-internal/src/analyzer/binder.ts

+19-11
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ interface NarrowExprOptions {
159159
// amount to the complexity factor. Without this, the complexity
160160
// calculation fails to take into account large numbers of non-cyclical
161161
// flow nodes. This number is somewhat arbitrary and is tuned empirically.
162-
const flowNodeComplexityContribution = 0.05;
162+
const flowNodeComplexityContribution = 0.025;
163163

164164
export class Binder extends ParseTreeWalker {
165165
private readonly _fileInfo: AnalyzerFileInfo;
@@ -4087,17 +4087,25 @@ export class Binder extends ParseTreeWalker {
40874087
// a decorator that tells us otherwise.
40884088
isInstanceMember = true;
40894089
for (const decorator of methodNode.d.decorators) {
4090+
let decoratorName: string | undefined;
4091+
40904092
if (decorator.d.expr.nodeType === ParseNodeType.Name) {
4091-
const decoratorName = decorator.d.expr.d.value;
4092-
4093-
if (decoratorName === 'staticmethod') {
4094-
// A static method doesn't have a "self" or "cls" parameter.
4095-
return undefined;
4096-
} else if (decoratorName === 'classmethod') {
4097-
// A classmethod implies that the first parameter is "cls".
4098-
isInstanceMember = false;
4099-
break;
4100-
}
4093+
decoratorName = decorator.d.expr.d.value;
4094+
} else if (
4095+
decorator.d.expr.nodeType === ParseNodeType.MemberAccess &&
4096+
decorator.d.expr.d.leftExpr.nodeType === ParseNodeType.Name &&
4097+
decorator.d.expr.d.leftExpr.d.value === 'builtins'
4098+
) {
4099+
decoratorName = decorator.d.expr.d.member.d.value;
4100+
}
4101+
4102+
if (decoratorName === 'staticmethod') {
4103+
// A static method doesn't have a "self" or "cls" parameter.
4104+
return undefined;
4105+
} else if (decoratorName === 'classmethod') {
4106+
// A classmethod implies that the first parameter is "cls".
4107+
isInstanceMember = false;
4108+
break;
41014109
}
41024110
}
41034111
}

0 commit comments

Comments
 (0)