mirror of
https://github.com/microsoft/pyright.git
synced 2024-08-15 10:50:44 +03:00
Fixed bug that results in unions consisting of different specialized forms of a generic TypedDict to "lose" all but one of these subtypes. This addresses #8169.
This commit is contained in:
parent
918bc4c745
commit
86715ec758
@ -3498,11 +3498,14 @@ function _addTypeIfUnique(unionType: UnionType, typeToAdd: UnionableType) {
|
||||
// If the typeToAdd is a TypedDict that is the same class as the
|
||||
// existing type, see if one of them is a proper subset of the other.
|
||||
if (ClassType.isTypedDictClass(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
|
||||
if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
|
||||
return;
|
||||
} else if (ClassType.isTypedDictNarrower(type, typeToAdd)) {
|
||||
unionType.subtypes[i] = typeToAdd;
|
||||
return;
|
||||
// Do not proceed if the TypedDicts are generic and have different type arguments.
|
||||
if (!type.typeArguments && !typeToAdd.typeArguments) {
|
||||
if (ClassType.isTypedDictNarrower(typeToAdd, type)) {
|
||||
return;
|
||||
} else if (ClassType.isTypedDictNarrower(type, typeToAdd)) {
|
||||
unionType.subtypes[i] = typeToAdd;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user