Author ncoghlan
Recipients larry, ncoghlan, yselivanov
Date 2015-05-19.06:24:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432016688.15.0.895702563372.issue20691@psf.upfronthosting.co.za>
In-reply-to
Content
I like the idea of the following signature:

    def signature(callable, *, follow_wrapped=True):
        ...

I'm less convinced about exposing the flag to optionally show the first positional arg for bound methods, as that's currently specific to method objects and builtins, rather than being a protocol like __wrapped__ that any callable can readily implement.

If we *did* do that, then I think we should follow the convention of naming it after an attribute we look for (in this case, __self__) rather than limiting it to a specific type, and also make it default to true for consistency.

That would give us:

    def signature(callable, *, follow_wrapped=True, omit_bound_self=True):
        ...

The "omit_bound_self" flag would then be documented along the following lines: "If 'omit_bound_self' is true, and the callable has a '__self__' attribute set to a value other than None, then the first positional argument will be hidden from the displayed signature. Setting this to false means that bound methods will be displayed the same"

However, as noted, I doubt the latter is worth it - let's just expose the flag to decide whether to resolve wrapper chains or not, and leave the inclusion of the already bound value in the reported signature solely as a legacy behaviour of getargspec and getfullargspec.
History
Date User Action Args
2015-05-19 06:24:48ncoghlansetrecipients: + ncoghlan, larry, yselivanov
2015-05-19 06:24:48ncoghlansetmessageid: <1432016688.15.0.895702563372.issue20691@psf.upfronthosting.co.za>
2015-05-19 06:24:48ncoghlanlinkissue20691 messages
2015-05-19 06:24:46ncoghlancreate