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. |


There is a known idiom for ensuring exhaustiveness of an
ifchain: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_exhaustivityIt 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: