Skip to content

Commit

Permalink
Fixed bug that led to an inconsistency between the use of type and …
Browse files Browse the repository at this point in the history
…`Type` when applying `isinstance` type narrowing in some cases. This addresses #6252.
  • Loading branch information
erictraut committed Oct 28, 2023
1 parent 6ed62b5 commit 7ef6ab2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/pyright-internal/src/analyzer/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,9 @@ export function convertToInstance(type: Type, includeSubclasses = true): Type {
}
} else {
if (subtype.typeArguments && subtype.typeArguments.length > 0) {
return convertToInstantiable(subtype.typeArguments[0]);
if (!isAnyOrUnknown(subtype.typeArguments[0])) {
return convertToInstantiable(subtype.typeArguments[0]);
}
}
}
}
Expand Down

0 comments on commit 7ef6ab2

Please sign in to comment.