Skip to content

Commit 5249e6a

Browse files
authored
Merge pull request #2778 from jku/type-fixes
2 parents 554f508 + 1a1312e commit 5249e6a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tuf/api/dsse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def from_bytes(cls, data: bytes) -> SimpleEnvelope[T]:
8181
except Exception as e:
8282
raise DeserializationError from e
8383

84-
return envelope
84+
return cast(SimpleEnvelope[T], envelope)
8585

8686
def to_bytes(self) -> bytes:
8787
"""Return envelope as JSON bytes.

tuf/api/serialization/json.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def serialize(self, signed_obj: Signed) -> bytes:
9898
"""
9999
try:
100100
signed_dict = signed_obj.to_dict()
101-
canonical_bytes = encode_canonical(signed_dict).encode("utf-8")
101+
canon_str = encode_canonical(signed_dict)
102+
# encode_canonical cannot return None if output_function is not set
103+
assert canon_str is not None # noqa: S101
104+
canonical_bytes = canon_str.encode("utf-8")
102105

103106
except Exception as e:
104107
raise SerializationError from e

0 commit comments

Comments
 (0)