Skip to content

Commit 871f68c

Browse files
committed
Add type hints for IDEs
Extend the type annotations with ones not needed by mypy but helping IDEs discover the return type of Metadata.from_bytes and give correct hints and suggestions. Signed-off-by: Teodora Sechkova <[email protected]>
1 parent 6aa5727 commit 871f68c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tuf/ngclient/_internal/trusted_metadata_set.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def update_root(self, data: bytes) -> None:
196196
logger.debug("Updating root")
197197

198198
try:
199-
new_root = Metadata[Root].from_bytes(data)
199+
new_root: Metadata[Root] = Metadata[Root].from_bytes(data)
200200
except DeserializationError as e:
201201
raise exceptions.RepositoryError("Failed to load root") from e
202202

@@ -261,7 +261,9 @@ def update_timestamp(self, data: bytes) -> None:
261261
raise RuntimeError("Cannot update timestamp after snapshot")
262262

263263
try:
264-
new_timestamp = Metadata[Timestamp].from_bytes(data)
264+
new_timestamp: Metadata[Timestamp] = Metadata[Timestamp].from_bytes(
265+
data
266+
)
265267
except DeserializationError as e:
266268
raise exceptions.RepositoryError("Failed to load timestamp") from e
267269

@@ -330,7 +332,9 @@ def update_snapshot(self, data: bytes) -> None:
330332
) from e
331333

332334
try:
333-
new_snapshot = Metadata[Snapshot].from_bytes(data)
335+
new_snapshot: Metadata[Snapshot] = Metadata[Snapshot].from_bytes(
336+
data
337+
)
334338
except DeserializationError as e:
335339
raise exceptions.RepositoryError("Failed to load snapshot") from e
336340

@@ -429,7 +433,7 @@ def update_delegated_targets(
429433
) from e
430434

431435
try:
432-
new_delegate = Metadata[Targets].from_bytes(data)
436+
new_delegate: Metadata[Targets] = Metadata[Targets].from_bytes(data)
433437
except DeserializationError as e:
434438
raise exceptions.RepositoryError("Failed to load snapshot") from e
435439

0 commit comments

Comments
 (0)