[Python-ideas] PEP 484 evolution

Rick Johnson rantingrickjohnson at gmail.com
Fri Mar 18 18:51:36 EDT 2016


@Everyone: Okay i'm completely confused as to were we are in
the "type hints" evolution. It seems to have taken all sorts
of random twists and turns -- will someone please explain?

(see examples below)

@Guido: i've skimmed PEP484, and i've read your handful of
"issues", but i need to know *EXACTLY* what a type hint
declaration will look like *BEFORE* i can offer my opinion
on these matters. At this point, i'm not overly concerned
about the dirty details of how type hints will be
implemented "under the hood", my first concern is, to
understand what *onerous* this feature will be placing on
the programmer, and, what *damage* it will could cause to
the "general readability" of Python source code. In other
words -- i need to decide if this is a good idea or not.

In pep484, the declaration seems to be firmly
coupled/interleaved with the source code:

    def greeting(name: str) -> str:
        return 'Hello ' + name

Oh my. But if so, i would hardly call this "a hint". Are we
going to introduce `->` as a method for defining the return
type of a function, and special-case `:` for binding types
to symbols in sigs?

But the rabbit hole goes deeper...

After reading PEP484, i'm looking over your list of issues,
and i see you using "magic comments" like this:

    def whatever(
             arg1,  # type: int
             arg2,  # type: int
             arg3,  # type: int
             arg4,  # type: str
             arg5,  # type: str
             arg6,  # type: str
             ):
        # type: (...) -> float
        # this is not a type comment (note that "..." above is literal)
        return (arg1 + arg2 + arg3 +
                float(arg4) + float(arg5) + float(arg6))

So which is it? The former? The latter? Or both?

PS: As i await your response, I'm praying to the FSM that
type hints will be implemented as the latter, and *NOT* the
former. And i'm *SO* fearful of the thought of the former,
that i'm *literally* shaking as i write this response--
*PLEASE* tell me it's the latter.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160318/206838df/attachment-0001.html>


More information about the Python-ideas mailing list