Skip to content

type(...) is treated the same as isinstance #5494

Closed

Activity

  1. added
    narrowingIssues with narrowing - root cause is usually narrowing, flow handling, or both
    on Nov 2, 2026
  2. added theissue type on Nov 2, 2026
  3. Divyansh151005 commented on Nov 4, 2026

    @Divyansh151005
    Contributor

    #claim

    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.

  4. github-actions commented on Nov 4, 2026

    @github-actions

    @Divyansh151005 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

  5. added a commit that references this issue on Nov 11, 2026
    4bfc9d6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

has-open-prnarrowingIssues with narrowing - root cause is usually narrowing, flow handling, or bothtypechecking

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions