<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 1, 2017 at 12:28 AM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 1 May 2017 at 03:07, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> There's a PR to the peps proposal here:<br>
> <a href="https://github.com/python/peps/pull/242" rel="noreferrer" target="_blank">https://github.com/python/<wbr>peps/pull/242</a><br>
><br>
> The full text of the current proposal is below. The motivation for this is<br>
> that for complex decorators, even if the type checker can figure out what's<br>
> going on (by taking the signature of the decorator into account), it's<br>
> sometimes helpful to the human reader of the code to be reminded of the type<br>
> after applying the decorators (or a stack thereof). Much discussion can be<br>
> found in the PR. Note that we ended up having `Callable` in the type because<br>
> there's no rule that says a decorator returns a function type (e.g.<br>
> `property` doesn't).<br>
<br>
</span>So a rigorous typechecker that understood the full decorator stack<br>
would be able to check whether or not the argument to `decorated_type`<br>
was correct, while all typecheckers (and human readers) would be able<br>
to just believe the argument rather than having to run through all the<br>
decorator transformations?<br></blockquote><div><br></div><div>Yes. In fact the intention is that the checker should check the declared type with the inferred and complain if they don't fit. In some cases the inferred type would have `Any` where the declared type would have a specific type and then the declared type would "win" (for uses of the decorated function) -- this is an example of where "erosion" in type inference can be counteracted by explicit declarations.<br></div></div><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>