From 836a1fcf9b3da4da352fefa6dc1e24bcd98dc5be Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 18 Dec 2021 18:34:48 -0700 Subject: [PATCH] Changed type logic to allow `type` to be assigned to `Type[T]`. In this case, `type` is treated the same as `Type[Any]`, so `T` receives a value of `Any`. --- .../pyright-internal/src/analyzer/typeEvaluator.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/pyright-internal/src/analyzer/typeEvaluator.ts b/packages/pyright-internal/src/analyzer/typeEvaluator.ts index 92672275a..00fda58cd 100644 --- a/packages/pyright-internal/src/analyzer/typeEvaluator.ts +++ b/packages/pyright-internal/src/analyzer/typeEvaluator.ts @@ -18751,6 +18751,16 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions } } + // If we're attempting to assign `type` to Type[T], transform `type` into `Type[Any]`. + if ( + TypeBase.isInstantiable(destType) && + isClassInstance(srcType) && + ClassType.isBuiltIn(srcType, 'type') && + !srcType.typeArguments + ) { + srcType = AnyType.create(); + } + const curEntry = typeVarMap.getTypeVar(destType); const curNarrowTypeBound = curEntry?.narrowBound; const curWideTypeBound = curEntry?.wideBound ?? destType.details.boundType;