[Python-ideas] PEP 484 (Type Hints) -- second draft

Terry Reedy tjreedy at udel.edu
Mon Mar 23 09:55:55 CET 2015


On 3/23/2015 2:02 AM, David Foster wrote:
> * It's a bit vague how local variables should be typed in the presence of
>    multiple assignments. Consider:
>
>    ```
>    if x > 0:
>        root = sqrt(x)  # type: int
>    else:
>        root = None
>    ```

root = sqrt(x) if x > 0 or None  # type: Union(int, None)

> * +1 for only allowing .pyi as the extension for stub files (and not
> also .py).
>    Makes it very clear that they should only be interpreted as stubs.

Agreed

> * +1 for the argument order cast(x, T). This is consistent with (x: T)
> elsewhere.

cast x to T and is x instance of T, agreed.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list