10000 Fixed bug that resulted in a false positive error when the second arg… · codean-io/scip-python@be6003a · GitHub
[go: up one dir, main page]

Skip to content

Commit be6003a

Browse files
committed
Fixed bug that resulted in a false positive error when the second argument to a type constructor call includes a tuple that includes a type class.
1 parent bd314fb commit be6003a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10890,7 +10890,12 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
1089010890
);
1089110891
arg1Type.tupleTypeArguments.forEach((typeArg) => {
1089210892
const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
10893-
if (isInstantiableClass(specializedType) || isAnyOrUnknown(specializedType)) {
10893+
10894+
if (
10895+
isInstantiableClass(specializedType) ||
10896+
isAnyOrUnknown(specializedType) ||
10897+
(isClassInstance(specializedType) && ClassType.isBuiltIn(specializedType, 'type'))
10898+
) {
1089410899
classType.details.baseClasses.push(specializedType);
1089510900
} else {
1089610901
addExpectedClassDiagnostic(typeArg.type, argList[1].valueExpression || errorNode);

packages/pyright-internal/src/tests/samples/newType2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ class B(X2, A):
2323

2424
# This should generate an error because the second arg is not a tuple of class types.
2525
X5 = type("X5", (3,))
26+
27+
28+
X6 = type("", tuple({str}), {})
29+
X7 = type("", (float, str), {})

0 commit comments

Comments
 (0)
0