mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +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,6 +3498,8 @@ 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)) {
|
||||
// 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)) {
|
||||
@ -3506,6 +3508,7 @@ function _addTypeIfUnique(unionType: UnionType, typeToAdd: UnionableType) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the typeToAdd is an empty container and there's already
|
||||
// non-empty container of the same type, don't add the empty container.
|
||||
|
Loading…
Reference in New Issue
Block a user