Exhaustiveness Checking with Mypy
import enum class OrderStatus(enum.Enum): Ready = ready Shipped = shipped You also have the following code to process an Order: def handle_order(status: OrderStatus) -> None: if status is OrderStatus.Ready: print(ship order) elif status is OrderStatus.Shipped: print(charge order) When the order is ready, you ship it; and when its shipped, you charge it. A few months go by and your system becomes big. So big in fact, that you can no longer ship orders immediately...
Daniel Rykhev Suit Equivalent To Union Optional Equivalent To Unionliteral Union Orderstatus Ready Orderstatus Shipped Orderstatus Scheduled
Source: hakibenita.com