Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 2:33 AM, Koos Zevenhoven wrote: > On Sun, Sep 4, 2016 at 2:22 AM, Chris Angelico wrote: >> On Sun, Sep 4, 2016 at 7:44 AM, Koos Zevenhoven wrote: I wonder if it would be different if you wrote that as a single expression: x = 1 if cond else 1.5 x =

Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 4:20 AM, Steven D'Aprano wrote: > On Sun, Sep 04, 2016 at 12:26:58AM +0300, Koos Zevenhoven wrote: >> On Friday, while replying to a post on python-dev about PEP 526 >> (variable annotations), I ended up mentioning things that I think a >> good type checker should do, which

Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-03 Thread Steven D'Aprano
On Sun, Sep 04, 2016 at 12:26:58AM +0300, Koos Zevenhoven wrote: > On Friday, while replying to a post on python-dev about PEP 526 > (variable annotations), I ended up mentioning things that I think a > good type checker should do, which seem to differ from the general > understanding. The discussi

Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-03 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 2:22 AM, Chris Angelico wrote: > On Sun, Sep 4, 2016 at 7:44 AM, Koos Zevenhoven wrote: >>> I wonder if it would be different if you wrote that as a single expression: >>> >>> x = 1 if cond else 1.5 >>> >>> x = sum([1] + [0.5] * cond) >>> >>> What should type inference deci

Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-03 Thread Chris Angelico
On Sun, Sep 4, 2016 at 7:44 AM, Koos Zevenhoven wrote: >> I wonder if it would be different if you wrote that as a single expression: >> >> x = 1 if cond else 1.5 >> >> x = sum([1] + [0.5] * cond) >> >> What should type inference decide x is in these cases? Assume an >> arbitrarily smart type chec

Re: [Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-03 Thread Koos Zevenhoven
Below I respond to Chris Angelico's post in the python-dev thread. On Sat, Sep 3, 2016 at 2:01 AM, Chris Angelico wrote: def eggs(cond:bool): if cond: x = 1 else: x = 1.5 spam(x) # a good type checker infers that x is of type Union[

[Python-ideas] Semantics for type checking (was: What should a good type checker do?)

2016-09-03 Thread Koos Zevenhoven
On Friday, while replying to a post on python-dev about PEP 526 (variable annotations), I ended up mentioning things that I think a good type checker should do, which seem to differ from the general understanding. The discussion should continue here, though, because the aim of PEP 526 is not to def