[issue27172] Add skip_bound_arg argument to inspect.Signature.from_callable()

Ryan Petrello report at bugs.python.org
Wed Jun 22 08:08:34 EDT 2016


Ryan Petrello added the comment:

Nick,

My use case is an issue of backwards compatibility and multiple Python version support for a library that makes prolific use of the legacy argspec (args, varargs, varkw, defaults) namedtuple, *including* the bound self argument behavior.  argspec and signature are quite different, and supporting a Py26-Py36 codebase that handles both simultaneously seemed like quite a burden, so I opted to write a compatibility shim that returned an Argspec-like object for all versions of Python;  this seemed the simplest approach to bridge the gap in a codebase that supports Python 2.6 through 3.6, and it's the approach that I've seen other major libraries (like Django) take:

https://github.com/pecan/pecan/pull/61

I'm using a similar approach to Python 3.5's getfullargspec() implementation:

https://github.com/python/cpython/blob/3.5/Lib/inspect.py#L1069

...but I don't have a long-term public API for doing it (so I have to rely on the private inspect._signature_from_callable call, which seems icky).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27172>
_______________________________________


More information about the Python-bugs-list mailing list