On Tue, 20 Nov 2018 at 13:50, Sebastian Rittau <srittau@rittau.biz> wrote:
On 20.11.18 14:02, Ivan Levkivskyi wrote:
Finally, I also don't think the current syntax is optimal, I would rather have `Optional` -> `Opt`, `Callable` -> `Call`, plus maybe some _limited_ amount of special forms (for example only unions and tuples, because they are actually special). But this is still relatively minor and can be partially fixed by `from typing import Optional as Opt`, etc.
I think the big wins would be unions and optional types. These are the big two that are frequently used and often nested. Another one is the callable syntax, because it is easy to make mistakes, but since we have protocol based syntax now this is less important for complicated cases. Shorthanding lists, dicts, and other fundamental container types is more problematic, especially since Iterable, Sequence, Mapping, etc. should be used more frequently in argument types
The main problem with special syntax for unions is that annotations, type aliases, generic base classes etc. are evaluated at runtime, so for example we will need to add `type.__or__()`. I could imagine many people will be against this. Also we still don't have any evidence (not even a Twitter poll) that verbose syntax is a problem in adoption of typing in Python. I would propose to postpone this discussion, unless there is a strong evidence this is a problem. -- Ivan