[Python-Dev] Is static typing still optional?

Guido van Rossum guido at python.org
Sun Dec 17 11:22:53 EST 2017


On Sun, Dec 17, 2017 at 2:11 AM, Julien Salort <listes at salort.eu> wrote:

> Le 15/12/2017 à 22:14, Paul Moore a écrit :
>
> Annotations and the annotation syntax are fundamental to the design.
>> But that's core Python syntax. But I wouldn't describe types as being
>> that significant to the design, it's more "if you supply them we'll
>> make use of them".
>>
> Naive question from a lurker: does it mean that it works also if one
> annotates with something that is not a type, e.g. a comment,
>
> @dataclass
> class C:
>     a: "This represents the amplitude" = 0.0
>     b: "This is an offset" = 0.0


I would personally not use the notation for this, but it is legal code.
However static type checkers like mypy won't be happy with this.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171217/3f0fa046/attachment.html>


More information about the Python-Dev mailing list