Skip to content

Use union for captured vars in or pattern #19710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2025

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Aug 21, 2025

Mypy creates a union type for the pattern subject in an or pattern already. Use union for captured variables as well.

@cdce8p cdce8p added the topic-match-statement Python 3.10's match statement label Aug 21, 2025
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks!

@hauntsaninja hauntsaninja merged commit 01e2a8c into python:master Aug 22, 2025
20 checks passed
@cdce8p cdce8p deleted the match-or-union branch August 22, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-match-statement Python 3.10's match statement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants