Repository navigation
Correct COSE signing header annotations for strict type checking - #707
Merged
Merged
Conversation
Accept parameterized dictionaries and ResolvedHeader for both signing headers. Document wrapper bypass semantics and add complementary signing regression coverage without changing runtime behavior or introducing new tooling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #707 +/- ##
=======================================
Coverage 97.01% 97.01%
=======================================
Files 32 32
Lines 3445 3445
=======================================
Hits 3342 3342
Misses 103 103 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks @achamayou! Verified locally: all tests and pre-commit checks pass, and Pyright strict now reports no diagnostics for I'll follow up separately to align the annotations of the other |
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.
Motivation
COSE.encode_and_signcurrently annotates its protected and unprotected headers asOptional[dict]. This causes two problems for strict type-checking consumers:reportUnknownMemberType.ResolvedHeader, although the implementation already accepts it.This blocks strict checking of
ccf.cosein microsoft/CCF#8675. This code needsResolvedHeaderto preserve application-defined labels and values without named-header resolution or value conversion.Changes
Optional[Union[Dict[Any, Any], ResolvedHeader]], matching the existing typing style and Python 3.10 support. ExplicitAnyaccommodates arbitrary header contents and preserves compatibility with parameterized dictionary callers.ResolvedHeaderand its bypass semantics in both parameter descriptions.None.CBORTagoutput.Runtime implementation, defaults, parameter ordering, serialization, cryptographic behavior, and the
Union[bytes, CBORTag]return annotation remain unchanged.Validation
ccf.coseproduces zero diagnostics across all 13 package modules; all 270 SDK tests pass. The patched wheel was installed inside the actual isolateduvxenvironment used for checking.This PR was produced with the help of AI, but I reviewed it entirely and believe the changes are correct.