Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Sep 25, 2022

Fixes #12886

contract_starred_pattern_types and expand_starred_pattern_types are sort of like inverses of each other, so you get crashes if contracted_inner_types and contracted_new_inner_types don't correspond (in the case that can_match gets set to False). When can_match is False, we don't need contracted_new_inner_types, so this PR just moves an if statement up a little bit and indent everything. I'm not sure can_match is doing anything useful, so this PR now just gets rid of it.

@hauntsaninja
Copy link
Collaborator Author

Hmm, it looks like there are no test cases (other than the new one) that actually hit the can_match logic. Maybe we can just remove it?

@hauntsaninja
Copy link
Collaborator Author

Okay, that seems to work and does simplify the code a little. I think there's some impact on reachability, but seemingly for the better in this case.

@github-actions

This comment has been minimized.

3 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@hauntsaninja hauntsaninja merged commit 176b052 into python:master Sep 26, 2022
@hauntsaninja hauntsaninja deleted the fix-match-star branch September 26, 2022 16:44
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.

False warnings and crash with dynamic class in match statement

2 participants