[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-14 Thread Noah Peter May
Fair enough , I can't say I have contributed to Mypy nor worked on a significantly large codebase. On Sat, Mar 14, 2020 at 2:12 PM Guido van Rossum wrote: > On Sat, Mar 14, 2020 at 1:03 PM Noah Peter May wrote: > >> Yeah, PEP 585 should definitely get pushed through! That would be super >>

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-14 Thread Guido van Rossum
On Sat, Mar 14, 2020 at 1:03 PM Noah Peter May wrote: > Yeah, PEP 585 should definitely get pushed through! That would be super > useful all around. > > Besides that, I think PEP 563 would mitigate most of the slowdown at > runtime introduced by 604. The only exceptions would be explicit like >

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-14 Thread Noah Peter May
Yeah, PEP 585 should definitely get pushed through! That would be super useful all around. Besides that, I think PEP 563 would mitigate most of the slowdown at runtime introduced by 604. The only exceptions would be explicit like assigning variables to types (int_list = List[int]) or dataclasses

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
On Sat, Mar 14, 2020 at 1:12 PM Inada Naoki wrote: > I'm sorry, I meant (a) looks more consistent with PEP 560. > Sorry again, I meant PEP 585, not PEP 560 as Guido explained already. -- Inada Naoki ___ Python-ideas mailing list --

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
On Sat, Mar 14, 2020 at 11:24 AM Inada Naoki wrote: > [snip] > a) Add `|` to all types. > b) Support it only statically (`from __future__ import annotations`). > [snip] > But (b) seems more consistent with PEP 560. > I'm sorry, I meant (a) looks more consistent with PEP 560. -- Inada Naoki

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Guido van Rossum
I think we should try to get PEP 604 accepted, with the runtime option (a), since that's the way we've gone already. PEP 604 proposes the right syntax, and I think mostly the right semantics (one could quibble about whether isinstance()/issubclass() ought to accept unions). Unfortunately it does

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
First of all, I am not so happy about typing is increasing Python runtime complexity. TypeScript is the most successful language with gradual typing. It has almost zero-cost about typing. It doesn't make JavaScript runtime complex. I hoped Python goes in same way. But Python went the different

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Wes Turner
Support for "| None" would be great to have. +1. https://github.com/python/peps/blob/master/pep-0604.rst On Fri, Mar 13, 2020, 9:36 AM Chris Angelico wrote: > On Sat, Mar 14, 2020 at 12:24 AM Noah Peter May wrote: > > > > Hello everyone, > > > > I'm not certain if this has been brought up

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Chris Angelico
On Sat, Mar 14, 2020 at 12:24 AM Noah Peter May wrote: > > Hello everyone, > > I'm not certain if this has been brought up before, but I felt like bringing > it to the table anyway. > > As the title says, it would be convenient to represent a union type with the > or operator. > Yep! You're