Skip to content

Commit bb62dde

Browse files
committed
Add type check
mypy warns about this but we know that encode_canonical() cannot return None if we don't set output_function argument. ruff does not like assert so I added a "noqa" and a comment Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 554f508 commit bb62dde

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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)