[Python-ideas] Optional static typing -- the crossroads

Nick Coghlan ncoghlan at gmail.com
Fri Aug 15 06:40:37 CEST 2014


On 15 August 2014 09:56, Guido van Rossum <guido at python.org> wrote:
>
> I don't buy the argument that PEP 3107 promises that annotations are
> completely free of inherent semantics.

It's also worth noting the corresponding bullet point in PEP 3100
(under http://www.python.org/dev/peps/pep-3100/#core-language):

* Add optional declarations for static typing [45] [10] [done]

[10] Guido's blog ("Python Optional Typechecking Redux")
http://www.artima.com/weblogs/viewpost.jsp?thread=89161
[45] PEP 3107 (Function Annotations) http://www.python.org/dev/peps/pep-3107

> It promises compatibility, and I take
> that very seriously, but I think it is reasonable to eventually deprecate
> other uses of annotations -- there aren't enough significant other uses for
> them to warrant crippling type annotations forever. In the meantime, we
> won't be breaking existing use of annotations -- but they may confuse a type
> checker, whether a stand-alone linter like mypy or built  into an IDE like
> PyCharm, and that may serve as an encouragement to look for a different
> solution.

Linters/checkers may also want to provide a configurable way to say
"the presence of decorator <X> means the annotations on that function
aren't type markers". That ties in with the recommendation we added to
PEP 8 a while back: "It is recommended that third party experiments
with annotations use an associated decorator to indicate how the
annotation should be interpreted."

> So there you have it. I am picking the mypy family and I hope we can start
> focusing on specific improvements to mypy. I also hope that somebody will
> write converters from pytypedecl and PyCharm stubs into mypy stubs, so that
> we can reuse the work already put into stub definitions for those two
> systems. And of course I hope that PyCharm and pytypedecl will adopt mypy's
> syntax (initially in addition to their native syntax, eventually as their
> sole syntax).

Having Argument Clinic generate appropriate annotations automatically
could also be interesting.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list