mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-06 21:07:19 +03:00
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
.
This commit is contained in:
parent
998a016f69
commit
836a1fcf9b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user