refactor(context): extract shared worker-compat metadata helper - #232
Merged
Conversation
Introduce _metadata_helpers.py housing the canonical copy_identity_attrs primitive and SAFE_IDENTITY_ATTRS tuple — the genuinely duplicated worker-compat logic shared with azure-functions-validation. _decorator.py now delegates identity-attribute copying to this primitive while keeping its package-specific signature/annotation mirroring. Closes #216
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Final item of #216. The
_copy_safe_metadatapattern (copy identity attrs onto a decorator wrapper without setting__wrapped__or aliasing__dict__, so the Azure Functions worker indexes the wrapper rather than the original handler) is duplicated inazure-functions-validation. This extracts the genuinely-shared primitive into a canonical home.Changes
_metadata_helpers.pywithcopy_identity_attrs()+SAFE_IDENTITY_ATTRS— a small, dependency-free primitive documented as the canonical shape to mirror across sibling packages (independent PyPI distributions with no shared base dependency, so "shared" = canonical synced definition, not a common import)._decorator.pynow delegates identity-attribute copying to the primitive, keeping its package-specific__signature__/__annotations__mirroring (logging preserves params; validation hides them — intentionally not unified).TestCopyIdentityAttrsasserting no__wrapped__and no__dict__aliasing.Follow-up to adopt the canonical helper in validation: yeongseon/azure-functions-validation-python#231.
Verification
make lintclean,make typecheckclean.Closes #216