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.

classification
Title: inspect.signature includes bound argument for wrappers around decorated bound methods
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: anton-ryzhov, yselivanov
Priority: normal Keywords:

Created on 2017-03-20 09:19 by anton-ryzhov, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 736 open anton-ryzhov, 2017-03-20 09:25
Messages (2)
msg289879 - (view) Author: (anton-ryzhov) * Date: 2017-03-20 09:19
If we wrap function with bound method, which is also a wrapper around function, `inspect.signature` will not do `skip_bound_arg`.
It will use `inspect.unwrap` and pass by bound method from outer function to inner one.

Reproduce:
```
import functools, inspect


def decorator(func):
    @functools.wraps(func)
    def inner(*args):
        return func(*args)
    return inner


class Foo(object):
    @decorator
    def bar(self, testarg):
        pass


f = Foo()
baz = decorator(f.bar)
assert inspect.signature(baz) == inspect.signature(f.bar)
```
msg289880 - (view) Author: (anton-ryzhov) * Date: 2017-03-20 09:19
Related to http://bugs.python.org/issue24298
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74044
2022-01-21 12:39:17iritkatrielsetversions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.7, Python 3.8
2019-04-10 00:01:03cheryl.sabellasetversions: + Python 3.8, - Python 3.5, Python 3.6
2017-03-20 09:35:21serhiy.storchakasetnosy: + yselivanov
stage: patch review
type: behavior

versions: - Python 3.3, Python 3.4
2017-03-20 09:25:29anton-ryzhovsetpull_requests: + pull_request650
2017-03-20 09:19:48anton-ryzhovsetmessages: + msg289880
2017-03-20 09:19:13anton-ryzhovcreate