Skip to content

Fix wraps for callables without attribute dictionaries - #125

Open
Aschenbath wants to merge 1 commit into
smarie:mainfrom
Aschenbath:fix/wrap-callables-without-dicts-94
Open

Aschenbath wants to merge 1 commit into
smarie:mainfrom
Aschenbath:fix/wrap-callables-without-dicts-94

Conversation

@Aschenbath

Copy link
Copy Markdown

Fixes #94.

wraps(object.__setattr__) and other callables without __dict__ currently raise AttributeError; wrapping a class also fails because its mappingproxy cannot be copied with copy.copy. Create a plain attribute dictionary with an empty default, preserving the existing shallow-copy and explicit-attribute override behavior.

Regression tests exercise builtins, method descriptors, slotted callables, their functools.partial wrappers, and classes. They check calls, signatures, __wrapped__, and that the original attributes stay unchanged. Added a changelog entry.

Validation on Python 3.12 / Windows:

  • Eight regression cases fail on the original source; the existing ordinary-function control passes.
  • The complete configured pytest suite passes: 104 passed, 1 existing skip. Coverage is 81%, above the configured 70% threshold.
  • git diff --check passes. The existing Flake8 configuration has an inline comment that Flake8 7.5 cannot parse. An isolated check using the configured line length and ignore codes reports the same seven existing unused typing-import diagnostics before and after the change, with no new diagnostics.

Prepared with Codex assistance; implementation and tests reviewed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wraps fails on decorating objects that miss or does not support __dict__ manipulation

1 participant