Skip to content

Chaining @wraps with non-modifying then modifying signatures leads to erroneous __wrapped__ flag been kept. #66

Closed

Description

@smarie
def a(foo):
    return foo + 1

assert a(1) == 2

# create a first wrapper that is signature-preserving

@wraps(a)
def wrapper(foo):
    return a(foo) - 1

assert wrapper(1) == 1

# the __wrapped__ attr is here:
assert wrapper.__wrapped__ is a

# create a second wrapper that is not signature-preserving

@wraps(wrapper, append_args="bar")
def second_wrapper(foo, bar):
    return wrapper(foo) + bar

assert second_wrapper(1, -1) == 0

with pytest.raises(AttributeError):
    second_wrapper.__wrapped__   # <---- does not raise ! 

Activity

  1. added
    bug
    on Mar 17, 2021
  2. added a commit that references this issue on Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions