Skip to content

Commit

Permalink
dsse: Improve type checking
Browse files Browse the repository at this point in the history
mypy rightly complains our types do not match (this only happen if you
enable type checks for securesystemslib):
* I think the annotation is actually wrong: Envelope does not know the
  contained type at this point.
* Likely SimpleEnvelope should not be generic: it does not relly know
  what it contains

I decided not to break the API here and just made the type cast
explicit (even though we don't really know that the cast is correct):
this silences mypy but has no other consequences.

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
jku committed Jan 31, 2025
1 parent bb62dde commit 1a1312e
Showing 1 changed file with 1 addition and 1 deletion.
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

0 comments on commit 1a1312e

Please sign in to comment.