Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect.signature includes bound argument for wrappers around decorated bound methods #74044

Closed
anton-ryzhov mannequin opened this issue Mar 20, 2017 · 2 comments
Closed
Labels
3.10 3.11 3.12 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anton-ryzhov
Copy link
Mannequin

anton-ryzhov mannequin commented Mar 20, 2017

BPO 29858
Nosy @1st1, @anton-ryzhov
PRs
  • gh-74044: inspect.signature for wrappers around decorated bound methods #736
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-03-20.09:19:13.208>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'inspect.signature includes bound argument for wrappers around decorated bound methods'
    updated_at = <Date 2022-01-21.12:39:17.450>
    user = 'https://github.com/anton-ryzhov'

    bugs.python.org fields:

    activity = <Date 2022-01-21.12:39:17.450>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2017-03-20.09:19:13.208>
    creator = 'anton-ryzhov'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29858
    keywords = []
    message_count = 2.0
    messages = ['289879', '289880']
    nosy_count = 2.0
    nosy_names = ['yselivanov', 'anton-ryzhov']
    pr_nums = ['736']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue29858'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @anton-ryzhov
    Copy link
    Mannequin Author

    anton-ryzhov mannequin commented Mar 20, 2017

    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.

    Reproducer:

    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)

    @anton-ryzhov anton-ryzhov mannequin added 3.7 stdlib Python modules in the Lib dir labels Mar 20, 2017
    @anton-ryzhov
    Copy link
    Mannequin Author

    anton-ryzhov mannequin commented Mar 20, 2017

    Related to http://bugs.python.org/issue24298

    @serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Mar 20, 2017
    @csabella csabella added the 3.8 label Apr 10, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added 3.12 and removed 3.9 labels Nov 9, 2022
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 10, 2022
    … methods (pythonGH-736)
    
    (cherry picked from commit dbf2faf)
    
    Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
    miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 10, 2022
    … methods (pythonGH-736)
    
    (cherry picked from commit dbf2faf)
    
    Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
    miss-islington added a commit that referenced this issue Nov 10, 2022
    …ds (GH-736)
    
    (cherry picked from commit dbf2faf)
    
    Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
    miss-islington added a commit that referenced this issue Nov 10, 2022
    …ds (GH-736)
    
    (cherry picked from commit dbf2faf)
    
    Co-authored-by: Anton Ryzhov <anton@ryzhov.me>
    ethanfurman pushed a commit to ethanfurman/cpython that referenced this issue Nov 12, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 3.11 3.12 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants