<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 14, 2014 at 1:24 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div class="">On Wed, Aug 13, 2014 at 3:26 PM, Manuel Cerón <span dir="ltr"><<a href="mailto:ceronman@gmail.com" target="_blank">ceronman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>The type checking algorithm might evolve over the time, but by including typing.py in the stdlib, the syntax for annotations would be almost frozen and that will be a limitation. In other projects such as TypeScript (<a href="http://www.typescriptlang.org/" target="_blank">http://www.typescriptlang.org/</a>), that the syntax usually evolves alongside the algorithms.</div>
</div></div></div></blockquote><div><br></div></div><div>What kind of evolution did TypeScript experience?</div></div></div></div></blockquote><div><br></div><div>There is a nice summary of breaking changes here: <a href="https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9">https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9</a></div>
<div><br></div><div>Most of these are in the way that the type checking engine works, but there are some syntax changes. While the basic types have remained stable, some special things have not. For example: generics, optional and default arguments, interfaces.</div>
<div><br></div><div>I think it'd be valuable to learn from TypeScript as much as possible, it's the only project that I know that It's trying to bring static type analysis to a widely used dynamically typed language.</div>
<div><br></div><div>One interesting feature of TypeScript is that it allows you to annotate existing code without modifying it, by using external definition files. In the JavaScript world, many people have contributed TypeScript annotation files for popular JS libraries (<a href="http://definitelytyped.org/">http://definitelytyped.org/</a>).</div>
<div><br></div><div>I think this is possible in Python as well doing something like this:</div><div><br></div><div>@annotate('math.ciel')</div><div>def ciel(x: float) -> int:</div><div> pass</div><div><br></div>
<div>I think this should be the way to go for annotating the stdlib. It has the advantage that if the type syntax changes, it's possible to provide new type annotations without changing the libraries at all, and even supporting older versions. In this way the code and type annotations can evolve separately.</div>
<div><br></div><div>Does mypy support something like this?</div><div><br></div><div>Manuel.</div></div></div></div>