Missing exceptions in PEP 3107

Christoph Zwerschke cito at online.de
Sun Aug 17 15:34:29 CEST 2008


Carl Banks schrieb:
> You are free to use it for other things.  For example, the following
> usage is obvious and sensible (insofar as listing exceptions is
> sensible):
> 
> def f(x : int) -> int, raises(TypeError)
> 
> Think of the return value annotation as more of a function outcome
> annotation.

That's fine, but then this should be mentioned in the PEP3107. Instead 
it says explicitly that the "->" syntax is for "the type of a function's 
return value". If it's intended to be used in a more general way like 
you suggested, then the wording used in the PEP is misleading. (The 
wording "*the* type is problematic anyway, since a Python function can 
return different types in different situations.)

It's still unclear for me whether annotations on thrown exceptions are 
included in PEP3107 (as per your suggestion), or are not covered by 
PEP3107 at all (as Duncan suggests), or whether this question has just 
not yet been settled.

-- Christoph




More information about the Python-list mailing list