You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plan: keep the isinstance-style narrowing for type(x) is C / type(x) == C, then, when C is a class literal, drop union members whose class is a proper subclass of C (a datetime can't have type(x) is date). bool literals are handled the same way (type(x) is int drops Literal[True]). NewType members and type[C] variables on the right-hand side are left alone, since those can still match at runtime.
Activity
Divyansh151005 commentedon Nov 4, 2026
#claim
Plan: keep the
isinstance-style narrowing fortype(x) is C/type(x) == C, then, whenCis a class literal, drop union members whose class is a proper subclass ofC(adatetimecan't havetype(x) is date).boolliterals are handled the same way (type(x) is intdropsLiteral[True]).NewTypemembers andtype[C]variables on the right-hand side are left alone, since those can still match at runtime.github-actions commentedon Nov 4, 2026
@Divyansh151005 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉
Narrow `type(x) is C` to exactly `C`, excluding subclasses
Narrow `type(x) is C` to exactly `C`, excluding subclasses (meta#5525)