-
Notifications
You must be signed in to change notification settings - Fork 233
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
Exhaustiveness checking util #735
Comments
Maybe static type checkers could add support for |
One added advantage of the For example with mypy:
|
I think commandeering |
With Pattern Matching now being accepted into python there might be renewed interest in this topic. I would suggest adding Type-checkers can then just be hardcoded to handle Type-checkers could also make sure that PS: Starting in April I will be writing my bachelors thesis on the topic of "Exhaustiveness check for Structural Pattern Matching in Python 3.10". My work will most likely be based on mypy and I'm planing to contribute the code back to upstream. Having an "official" way to annotate exhaustiveness would be really useful for me. |
Just as cross-reference for people following this issue: there's been some recent movement towards adding an |
assert_never has been merged, closing this. |
There is a known idiom for ensuring exhaustiveness of an
if
chain:python/mypy#5818
It works with mypy but I have not tested it with other type checkers.
Because it is not in the standard library, it has to be implemented or imported in many projects that use typing. At my workplace, we have this util under the name
assert_exhaustivity
It would be helpful to document this idiom and have it in the standard library. Would a pull request to this repository be the right way to make it happen? Or does it need a PEP?
The text was updated successfully, but these errors were encountered: