Nick Coghlan added the comment:

Ah, unfortunately, on closer inspection, even partial itself ends up suffering 
from the same problem as the current inspect.wraps - validation ultimately 
happens at the point of calling the original wrapper function, so if you don't 
actually call it, you won't get any argument validation.

You can use 
https://docs.python.org/3/library/inspect.html#inspect.Signature.bind to force 
early validation without actually calling the underlying callable, but that's 
always going to be substantially slower than "just try it and see if it works". 
functools is also further down in the stdlib dependency hierarchy than the 
inspect module so it isn't possible to offer that behaviour without creating a 
circular dependency.

What would be possible is to point out explicitly that "wraps" only updates 
introspection metadata, and if you're after eager argument validation (e.g. 
before queuing a command for delayed execution), then you likely want 
inspect.Signature.bind.

----------
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
title: Accept a separate "call_target" parameter to functools.partial -> 
Reference inspect.Signature.bind from functools.wraps documentation
versions: +Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23764>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to