Hi,

I was wondering if the following idea would be a useful addition to the
Python language and if it could use a new PEP.
I personally find myself often looking into the documentation &
implementation of libraries I use to try and figure out what exceptions
a function may raise.

In the same vein as adding type annotations to code, I think it'd be
very useful to have exception "raises" annotations, i.e. a way to
annotate what exceptions a function raises. Again, like type
annotations, it shouldn't be mandatory nor actually be enforced at
runtime. It would purely serve as a feature that IDEs can make use of.

An example of how it may look:

def divide(numerator: float, denominator: float) raises [ZeroDivisionError] -> 
float:
    return numerator / denominator

I'd love to know if this is an idea you'd be interested in having added
to the language.

Kind regards,
Sergio Fenoll
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LFUZR6NH35HOLTVGV5YRB6457KZ2KJ5A/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to