Fixed bug that results in a spurious reportAbstractUsage error when an abstract class is captured through a type[T]. This addresses #7680. (#7681)

This commit is contained in:
Eric Traut 2024-04-12 23:10:30 -07:00 committed by GitHub
parent 92f2284d24
commit dfe428190c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4267,7 +4267,6 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
// it represents an instance of a type. If the replacement includes
// a generic class that has not been specialized, specialize it
// now with default type arguments.
if (this._options.unknownIfNotFound) {
replacement = mapSubtypes(replacement, (subtype) => {
if (isClassInstance(subtype)) {
// If the includeSubclasses wasn't set, force it to be set by
@ -4276,13 +4275,14 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
subtype = ClassType.cloneAsInstance(ClassType.cloneAsInstantiable(subtype));
}
if (this._options.unknownIfNotFound) {
return specializeWithDefaultTypeArgs(subtype);
}
}
return subtype;
});
}
}
if (isTypeVar(replacement) && typeVar.isVariadicUnpacked && replacement.details.isVariadic) {
return TypeVarType.cloneForUnpacked(replacement, typeVar.isVariadicInUnion);