[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 11:52, Chris Angelico escribiu: But requests.get() doesn't have a single raise statement anywhere in it. And if you dig through the entire source code for the requests package, you'll still only find a small number of the exceptions that might be raised. Errors come from anywhere, a

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 11:34, Chris Angelico escribiu: On Fri, Sep 25, 2020 at 7:19 PM Sergio Fenoll wrote: O 25/09/20 ás 10:56, Chris Angelico escribiu: There's the shallow "exceptions that I expect to raise", which is those explicitly listed within the function as raise statements;

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 06:23, Stephen J. Turnbull escribiu: Sergio Fenoll writes: > 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. I t

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 10:56, Chris Angelico escribiu: There's the shallow "exceptions that I expect to raise", which is those explicitly listed within the function as raise statements; but that's not the whole story, since exceptions can be raised by anything that the function calls. So, no, I don't thi

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 10:02, Chris Angelico escribiu: On Fri, Sep 25, 2020 at 5:09 PM Sergio Fenoll wrote: O 25/09/20 ás 08:41, Chris Angelico escribiu: It would have to not only look at get(), but everything that it calls. Either that, or you're back to the Java thing of "catch it or

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 09:12, Serhiy Storchaka escribiu: Did not the experience of C++ show that exceptions declaration was a bad idea? In C++ it was optional and is abandoned now. Java developers still suffer from necessary to declare all raised exception, or just declare the most general exception class

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-25 Thread Sergio Fenoll
O 25/09/20 ás 08:41, Chris Angelico escribiu: On Fri, Sep 25, 2020 at 4:25 PM Sergio Fenoll wrote: What I had in mind was that an IDE could use this information to show autocomplete options when writing except blocks. The other day I was writing some code like this: import requests try

[Python-ideas] Re: Suggestion: annotated exceptions

2020-09-24 Thread Sergio Fenoll
O 25/09/20 ás 07:37, Steven D'Aprano escribiu: I think that it's a truism that any function written in Python could raise any exception :-) In practice, though, I think it is reasonable to say that functions will *typically* but not necessarily exclusively raise a certain set of exceptions. Wh

[Python-ideas] Suggestion: annotated exceptions

2020-09-24 Thread Sergio Fenoll
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 l