[Python-ideas] Proposal to extend PEP 484 (gradual typing) to support Python 2.7

Pavol Lisy pavol.lisy at gmail.com
Mon Jan 11 17:41:17 EST 2016


2016-01-11 22:52 GMT+01:00, Guido van Rossum <guido at python.org>:
> On Mon, Jan 11, 2016 at 1:48 PM, Pavol Lisy <pavol.lisy at gmail.com> wrote:
>
>> What about this?
>>
>> def embezzle(self, account: "PEP3107 annotation"):
>>     # type: (str) -> Any
>>     """Embezzle funds from account using fake receipts."""
>>     <code goes here>
>>
>
> I don't understand your proposal -- this is not valid Python 2.7 syntax so
> we cannot use it.

I had two things in my mind:

1. suggest some possible impact in the future.

In time we are writing code compatible with python2 and python3 we
will have type hints comments under python3 too.

And because they are more compatible, there is risk(?) that they could
be more popular then original PEP484 (for python3) proposal!

2. PEP484 describe possibility how to support other use of annotations
and propose to use

   # type: ignore

but similar method how to preserve other use of annotations could be
(for example):

   # type: (str) -> Any

and this could combine goodness of type-hints-tools and other types of
annotations. At least in deprecation period (if there will be any) for
other annotation types.


More information about the Python-ideas mailing list