A proposal for java's "throws" in python: Extend type hints to cover exceptions - eviltoast

This is a discussion on Python’s forums about adding something akin to a throws keyword in python.

  • qwertyasdef@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    1 year ago

    Hey, I like checked exceptions too! I honestly think it’s one of Javas’s best features but it’s hindered by the fact that try-catch is so verbose, libraries aren’t always sensible about what exceptions they throw, and methods aren’t exception-polymorphic for stuff like the Stream API. Which is to say, checked exceptions are a pain but that’s the fault of the rest of the language around them and not the checked exceptions per se.