[Python-ideas] PEP 484 (Type Hints) -- first draft round

Stephen Hansen me+python at ixokai.io
Tue Jan 20 08:52:01 CET 2015

> The difference is that the :: annotations would *not* be
> evaluated a run time. There's currently no way to get
> that with a decorator, or anything else in the language,
> short of abusing comments or string literals.
> Yet it's what you really want for static type checking.

We already have : annotations.

If you don't want evaluation at run time, "abuse" string literals -- all
you're doing is removing the need to put quotes around the argument. Typing
two characters is a very poor justification for new syntax. Especially when
its at the cost of making the whole thing horribly more complex by having
two syntaxes for essentially the same thing ... and especially when they
look confusingly similar and there is no intuitive way to make a
distinction between them.

def foo(bar: int:: whatever):

Please, no.

We really, really, really do not need two kinds of annotations that look
essentially identical.

def foo(bar: 'int'):

if what you "really want" for static type checking is no evaluation, is no
big deal. x : 'xyz' is how you spell 'not evaluating' and its only one
extra character to type.

As an aside, I'm not convinced that what you really want for static type
checking is no evaluation, since mypy seems seems to work just fine with
evaluation or strings either way.

-1 on a second form of annotations. Its like giving a dog a hat, you might
think it keeps its ears dry but the dog doesn't need it and looks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150119/793c0ce5/attachment.html>

More information about the Python-ideas mailing list