Fixed bug that leads to incorrect metatype for a class object that is created by calling the metaclass with a two-argument form.

This commit is contained in:
Eric Traut 2024-04-23 21:58:46 -07:00
parent d33a1051dd
commit e5c0b59c77
2 changed files with 11 additions and 5 deletions

View File

@ -12958,7 +12958,7 @@ export function createTypeEvaluator(
fileInfo.fileUri,
ClassTypeFlags.ValidTypeAliasClass,
ParseTreeUtils.getTypeSourceId(errorNode),
/* declaredMetaclass */ undefined,
metaclass,
arg1Type.details.effectiveMetaclass
);
arg1Type.tupleTypeArguments.forEach((typeArg) => {

View File

@ -7,12 +7,10 @@ X1 = type("X1", (object,), {})
X2 = type("X2", (object,), {})
class A(X1):
...
class A(X1): ...
class B(X2, A):
...
class B(X2, A): ...
# This should generate an error because the first arg is not a string.
@ -27,3 +25,11 @@ X5 = type("X5", (3,))
X6 = type("", tuple({str}), {})
X7 = type("", (float, str), {})
class Meta1(type): ...
X8 = Meta1("X8", (list,), {})
reveal_type(X8, expected_text="type[X8]")
reveal_type(type(X8), expected_text="type[Meta1]")