Skip to content
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

Make ValuePattern non-exhaustive #12751

Merged
merged 1 commit into from
May 9, 2022
Merged

Make ValuePattern non-exhaustive #12751

merged 1 commit into from
May 9, 2022

Conversation

shoracek
Copy link
Contributor

@shoracek shoracek commented May 8, 2022

Description

Changes behaviour of PatternChecker, so that dotted names do not cover the entire type.
Since dotted names match only one value of the type, the returned rest_type should also contain the type of the value.

Fixes: #12545

Test Plan

Included code similar to the one from the issue, modified into one file.

Changes behaviour of PatternChecker so that ValuePattern does not cover
the entire type since it can catch only a single value.

Signed-off-by: Štěpán Horáček <xhorace2@fi.muni.cz>
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2022

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

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think that there are some edge cases where this doesn't work right, but this seems overall an improvement, as it fixes a common case.

@JukkaL JukkaL merged commit e1c03ab into python:master May 9, 2022
@JukkaL
Copy link
Collaborator

JukkaL commented May 9, 2022

I think that there are some edge cases where this doesn't work right, but this seems overall an improvement, as it fixes a common case.

Actually, I'm not sure if this is the case. The edge case that I was thinking about actually was fine.

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.

mypy incorrectly identifies statements as unreachable when matching against constants
2 participants