[Python-ideas] Using rightarrow "->" for typing annotation of functions
vaibhavskarve at gmail.com
Wed Apr 24 17:29:06 EDT 2019
(Note: This idea is about a particular static typecheking (typing?)
The idea is that currently the use of the "->" (right arrow) is restricted
to only function definition annotation. Can we extent it to declaration of
type for functions even outside their definitions?
Currently we write:
f: Callable[[int, Dict[str, int]], str] # declaring the type of some
This would be much cleaner if we could write:
f: int -> Dict[str, int] -> str # One of the possibilities
f: int, Dict[str, int] -> str # Another possibility
I have no idea how this will affect the existing syntax (and if this will
have any bad repercussions/notational misuse). I just thought it would be
a) Not have to spell out Callable
b) Not have to use all those square brackets
c) Have the same notation work for both the function annotation as well as
for declaring the type.
This is my first time posting an idea to python-ideas. So apologies if i am
not following some conventions that i might not be aware of.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas