[Python-ideas] Proposed PEP 484 addition: describe a way of annotating decorated declarations

Nick Coghlan ncoghlan at gmail.com
Mon May 1 03:28:31 EDT 2017

On 1 May 2017 at 03:07, Guido van Rossum <guido at python.org> wrote:
> There's a PR to the peps proposal here:
> https://github.com/python/peps/pull/242
> The full text of the current proposal is below. The motivation for this is
> that for complex decorators, even if the type checker can figure out what's
> going on (by taking the signature of the decorator into account), it's
> sometimes helpful to the human reader of the code to be reminded of the type
> after applying the decorators (or a stack thereof). Much discussion can be
> found in the PR. Note that we ended up having `Callable` in the type because
> there's no rule that says a decorator returns a function type (e.g.
> `property` doesn't).

So a rigorous typechecker that understood the full decorator stack
would be able to check whether or not the argument to `decorated_type`
was correct, while all typecheckers (and human readers) would be able
to just believe the argument rather than having to run through all the
decorator transformations?

Make sense to me.


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

More information about the Python-ideas mailing list