Skip to content

Commit

Permalink
Merge pull request #2778 from jku/type-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jku authored Jan 31, 2025
2 parents 554f508 + 1a1312e commit 5249e6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tuf/api/dsse.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def from_bytes(cls, data: bytes) -> SimpleEnvelope[T]:
except Exception as e:
raise DeserializationError from e

return envelope
return cast(SimpleEnvelope[T], envelope)

def to_bytes(self) -> bytes:
"""Return envelope as JSON bytes.
Expand Down
5 changes: 4 additions & 1 deletion tuf/api/serialization/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def serialize(self, signed_obj: Signed) -> bytes:
"""
try:
signed_dict = signed_obj.to_dict()
canonical_bytes = encode_canonical(signed_dict).encode("utf-8")
canon_str = encode_canonical(signed_dict)
# encode_canonical cannot return None if output_function is not set
assert canon_str is not None # noqa: S101
canonical_bytes = canon_str.encode("utf-8")

except Exception as e:
raise SerializationError from e
Expand Down

0 comments on commit 5249e6a

Please sign in to comment.