Fixed regression that affected type narrowing of subscript expressions for TypedDict objects.

This commit is contained in:
Eric Traut 2021-08-11 09:28:50 -07:00
parent ae2cb23bbc
commit fbb0d521ee

View File

@ -5401,7 +5401,10 @@ export function createTypeEvaluator(
// passed to __setitem__ is the same type as the value returned by __getitem__).
let baseTypeSupportsIndexNarrowing = true;
mapSubtypesExpandTypeVars(baseTypeResult.type, /* conditionFilter */ undefined, (subtype) => {
if (!isClassInstance(subtype) || !ClassType.isBuiltIn(subtype)) {
if (
!isClassInstance(subtype) ||
!(ClassType.isBuiltIn(subtype) || ClassType.isTypedDictClass(subtype))
) {
baseTypeSupportsIndexNarrowing = false;
}