Skip to content

Fix UnsetType truthiness narrowing in type stubs#975

Merged
jcrist merged 2 commits intojcrist:mainfrom
overlorde:fix-unset-type-narrowing
Apr 8, 2026
Merged

Fix UnsetType truthiness narrowing in type stubs#975
jcrist merged 2 commits intojcrist:mainfrom
overlorde:fix-unset-type-narrowing

Conversation

@overlorde
Copy link
Copy Markdown
Contributor

Summary

  • Add __bool__() -> Literal[False] to UnsetType stub so type checkers can narrow T | UnsetType via truthiness (if x:)
  • Add typing test for truthiness-based narrowing

Closes #916

@overlorde
Copy link
Copy Markdown
Contributor Author

CI note: both failures are unrelated to this change.

@Siyet
Copy link
Copy Markdown
Collaborator

Siyet commented Apr 8, 2026

Ported to the community fork msgspec-arise: PR #33

Copy link
Copy Markdown
Owner

@jcrist jcrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jcrist jcrist merged commit c01df28 into jcrist:main Apr 8, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnsetType union types lowering is incomplete

4 participants