[Python-ideas] Trial balloon: adding variable type declarations in support of PEP 484

Guido van Rossum guido at python.org
Fri Aug 5 18:39:40 EDT 2016


On Fri, Aug 5, 2016 at 3:37 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Fri, Aug 5, 2016 at 10:41 AM, Guido van Rossum <guido at python.org> wrote:
>> Actually my current leaning is as follows:
>>
>> [for modules: evaluate and store in mod.__annotations__]
>> [for classes: evaluate and store in cls.__annotations__]
>> [for function bodies: recognize but do not evaluate]
>
> I wonder if that distinction will bias anyone away from using
> annotations in function bodies (or using them at all).  Probably not
> significantly.

My current bias is towards not using annotations in function bodies
unless mypy insists on them (as it does in some corner cases where the
type inference falls short or requires too much looking ahead). In
classes my bias is towards fully specifying all instance variables,
because they serve an important documentation purpose.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list