[Python-ideas] Typecheckers: there can be only one

Hugh Fisher hugo.fisher at gmail.com
Thu Sep 8 05:46:41 EDT 2016


On Thu, Sep 8, 2016 at 8:00 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>
>> Type annotations are code, not tests.
>
> Not in Python they aren't.
>

The interpreter certainly thinks they're code rather than comments or
docstrings, even before PEP 526. I type this into my Python 3.4
interpreter:

>>> def foo(x:itn):
>>> ... return x

and the interpreter raises a NameError because 'itn' is not defined.

Annotations look like code, they're mixed in with names and operators
and literals and keywords, and all the standard syntax and semantic
checks are applied.

-- 

        cheers,
        Hugh Fisher


More information about the Python-ideas mailing list