This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients docs@python, ncoghlan, productivememberofsociety666, r.david.murray, rhettinger
Date 2015-03-26.01:05:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1427331934.56.0.414849367769.issue23764@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-03-26 01:05:34ncoghlansetrecipients: + ncoghlan, rhettinger, r.david.murray, docs@python, productivememberofsociety666
2015-03-26 01:05:34ncoghlansetmessageid: <1427331934.56.0.414849367769.issue23764@psf.upfronthosting.co.za>
2015-03-26 01:05:34ncoghlanlinkissue23764 messages
2015-03-26 01:05:34ncoghlancreate