Skip to content

Commit 1d03f54

Browse files
committed
Fixed a bug that resulted in spurious type evaluation errors when dealing with classes that have synthesized symbols such as dataclasses, namedtuples and TypedDicts. This addresses microsoft/pylance-release#4151.
1 parent 6e43a0f commit 1d03f54

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16389,7 +16389,9 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
1638916389

1639016390
// The scope for this class becomes the "fields" for the corresponding type.
1639116391
const innerScope = ScopeUtils.getScopeForNode(node.suite);
16392-
classType.details.fields = innerScope?.symbolTable || new Map<string, Symbol>();
16392+
classType.details.fields = innerScope?.symbolTable
16393+
? new Map<string, Symbol>(innerScope.symbolTable)
16394+
: new Map<string, Symbol>();
1639316395

1639416396
// Determine whether the class's instance variables are constrained
1639516397
// to those defined by __slots__. We need to do this prior to dataclass

0 commit comments

Comments
 (0)