Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Guido van Rossum
On Tue, Sep 6, 2016 at 8:25 AM, Mark Shannon wrote: > The "smartness" of checkers is not the problem (for this example, at least) > the problem is that checkers must conform to the rules laid down in PEP 484 > and (in whatever form it finally takes) PEP 526. > It sounds like mypy

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Chris Angelico
On Wed, Sep 7, 2016 at 4:11 AM, Stephen J. Turnbull wrote: > Finally, the notion of annotating expressions is incoherent: > > # Annotating (sub)expressions: the more the merrier! > (x) : bool = (((y): int + (z): float) / (w): complex): quarternion >

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Stephen J. Turnbull
Mark Shannon writes: > The problem with using the term "variable" is that it is *not* vague. > Variables in python have well defined scopes and lifetimes. Sure, but *hints* are not well-defined by Python (except the syntax, once PEP 526 is implemented). A *hint* is something that the

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Ivan Levkivskyi
On 6 September 2016 at 18:35, Nick Coghlan wrote: > On 7 September 2016 at 01:33, Ivan Levkivskyi > wrote: > > On 6 September 2016 at 17:25, Mark Shannon wrote: > >> > >> The issue is not whether the checker can tell that the type of

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Nick Coghlan
On 7 September 2016 at 01:33, Ivan Levkivskyi wrote: > On 6 September 2016 at 17:25, Mark Shannon wrote: >> >> The issue is not whether the checker can tell that the type of the >> *expression* is int, but whether it is forced to use the type of the >>

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Ivan Levkivskyi
On 6 September 2016 at 17:25, Mark Shannon wrote: > The issue is not whether the checker can tell that the type of the > *expression* is int, but whether it is forced to use the type of the > *variable*. The current wording of PEP 526 strongly implies the latter. > Mark, Could

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Mark Shannon
On 05/09/16 18:40, Guido van Rossum wrote: On Mon, Sep 5, 2016 at 8:26 AM, Mark Shannon wrote: PEP 526 states that "This PEP aims at adding syntax to Python for annotating the types of variables" and Guido seems quite insistent that the declarations are for the types of

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-06 Thread Mark Shannon
On 05/09/16 23:16, Greg Ewing wrote: Mark Shannon wrote: Unless of course, others may have a different idea of what the "type of a variable" means. To me, it means it means that for all assignments `var = expr` the type of `expr` must be a subtype of the variable, and for all uses of var,

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Koos Zevenhoven
On Tue, Sep 6, 2016 at 1:49 AM, Sven R. Kunze wrote: > Didn't Koos say this works more like an expression annotation? > > IMO, the type of the expression is what is specified but the type of the > variable can change over time (as you demonstrated). That's exactly the kind of

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Sven R. Kunze
Didn't Koos say this works more like an expression annotation? IMO, the type of the expression is what is specified but the type of the variable can change over time (as you demonstrated). Sven PS: thinking this way, the new syntax is actually confusing as it annotates the variable not the

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Peter Ludemann via Python-Dev
I would take the opposite approach from Greg Ewing, namely that the annotation is not a permission of values but a starting point for the type inferencer; and the type checker/inferencer can complain if there's an inconsistency (for some definition of "inconsistency", which is not defined in the

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Greg Ewing
Mark Shannon wrote: Unless of course, others may have a different idea of what the "type of a variable" means. To me, it means it means that for all assignments `var = expr` the type of `expr` must be a subtype of the variable, and for all uses of var, the type of the use is the same as the

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Steven D'Aprano
On Mon, Sep 05, 2016 at 04:26:17PM +0100, Mark Shannon wrote: > In this example: > > def bar()->Optional[int]: ... > > def foo()->int: > x:Optional[int] = bar() > if x is None: > return -1 > return x > > According to PEP 526 the annotation

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Guido van Rossum
On Mon, Sep 5, 2016 at 8:26 AM, Mark Shannon wrote: > PEP 526 states that "This PEP aims at adding syntax to Python for annotating > the types of variables" and Guido seems quite insistent that the > declarations are for the types of variables. > > However, I get the impression

Re: [Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Ryan Gonzalez
Maybe the PEP should just say it's for "annotating variables", and it would mention "primarily for the purpose of types"? -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong. http://kirbyfan64.github.io/ On Sep 5, 2016 10:27 AM, "Mark Shannon"

[Python-Dev] Do PEP 526 type declarations define the types of variables or not?

2016-09-05 Thread Mark Shannon
Hi, PEP 526 states that "This PEP aims at adding syntax to Python for annotating the types of variables" and Guido seems quite insistent that the declarations are for the types of variables. However, I get the impression that most (all) of the authors and proponents of PEP 526 are quite