mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 16:06:39 +03:00
Fixed a bug that led to a false positive error when using a subclass of type
as a base class in a class declaration. This addresses https://github.com/microsoft/pyright/issues/4737.
This commit is contained in:
parent
dbe9e3ab88
commit
315031a47b
@ -15983,7 +15983,13 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
}
|
||||
|
||||
if (!isAnyOrUnknown(argType) && !isUnbound(argType)) {
|
||||
if (isClass(argType) && TypeBase.isInstance(argType) && ClassType.isBuiltIn(argType, 'type')) {
|
||||
if (
|
||||
isClass(argType) &&
|
||||
TypeBase.isInstance(argType) &&
|
||||
argType.details.mro.some(
|
||||
(mroClass) => isClass(mroClass) && ClassType.isBuiltIn(mroClass, 'type')
|
||||
)
|
||||
) {
|
||||
argType =
|
||||
argType.typeArguments && argType.typeArguments.length > 0
|
||||
? argType.typeArguments[0]
|
||||
|
@ -1987,9 +1987,16 @@ export function isEffectivelyInstantiable(type: Type): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle the special case of 'type', which is instantiable.
|
||||
if (isClassInstance(type) && ClassType.isBuiltIn(type, 'type')) {
|
||||
return true;
|
||||
// Handle the special case of 'type' (or subclasses thereof),
|
||||
// which are instantiable.
|
||||
if (isClassInstance(type)) {
|
||||
if (
|
||||
type.details.mro.some((mroClass) => {
|
||||
return isClass(mroClass) && ClassType.isBuiltIn(mroClass, 'type');
|
||||
})
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUnion(type)) {
|
||||
|
Loading…
Reference in New Issue
Block a user