Skip to content

Preserve intermediate wrapped functions in stacked decorators - #188

Merged
micheles merged 2 commits into
micheles:masterfrom
jakezwang:fix/preserve-wrapper-chain
Oct 8, 2026
Merged

micheles merged 2 commits into
micheles:masterfrom
jakezwang:fix/preserve-wrapper-chain

Conversation

@jakezwang

@jakezwang jakezwang commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Set __wrapped__ after copying the wrapped function's attributes, so stacked decorators retain the immediate wrapper instead of skipping a layer. Apply the same ordering to decorator factories whose caller is already wrapped.

Add regressions for one-layer bypass, inspect.unwrap, and wrapped callers.

Earlier validation: 28 tests and 118 doctests on Python 3.8–3.14; flake8 and codespell passed. After the conditional-wrapper update, source mypy and stubtest pass on Python 3.14. A fresh Python 3.11 stubtest run is blocked by the unchanged stub file importing annotationlib, which is not available on that Python version.

@micheles

Copy link
Copy Markdown
Owner

Thanks for your contribution, but I see a small issue with the stubtest; can you check that?

Signed-off-by: Jake Wang <jake.wang@argonlabs.tech>
@micheles
micheles merged commit fb40e86 into micheles:master Oct 8, 2026
8 checks passed
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.

2 participants