Twitter user @DanyX23:
TIL: pyright, the python type checking engine that is used by VS Code, has support for exhaustiveness checking for match statements with union types!
If you add the following to your pyproject.toml, you’ll get the attached warning
[tool.pyright] reportMatchNotExhaustive = true
I see three possible ways to go about errors:
The criticism I have to Python exceptions is that there should be a way to explicitly see the exceptions a function raises, maybe as part of the function signature like in Java.
To put it another way, I don’t think errors as returned values are immediately better than exceptions. I like the way Rust handles them for instance, but an unsuccessful .unwrap() is not that different from an unhandled exception. I just wish the possible exceptions raised were explicitly stated.