Skip to content

Conversation

@eladshoshani
Copy link

@eladshoshani eladshoshani commented Apr 23, 2024

Implements #17152
Fixes #17149

Summary

This PR adds to mypy the ability to recognize conditions like if None in [a, b, c]: and refine the types of a, b, c in the relevant scope. The supported expressions are ListExpr, TupleExpr, SetExpr.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@eladshoshani eladshoshani marked this pull request as ready for review April 23, 2024 11:49
@eladshoshani
Copy link
Author

The new feature is ready and I tested it on all kinds of code samples, but something in the automatic tests that I added in the check-optional.test file got stuck.
I don't have any more time right now to work on the feature, so I leave the correction/deletion of these tests to the CR

@github-actions
Copy link
Contributor

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

@KazMiddelhoek
Copy link

Are there plans to merge this PR? Would be a great feature!

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.

Type refinement does not work with None in [a, b, c], any(), or all() checks

2 participants