Skip to content

Commit

Permalink
Add type hints for IDEs
Browse files Browse the repository at this point in the history
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 <tsechkova@vmware.com>
  • Loading branch information
sechkova committed Jul 28, 2021
1 parent 6aa5727 commit 871f68c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tuf/ngclient/_internal/trusted_metadata_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def update_root(self, data: bytes) -> None:
logger.debug("Updating root")

try:
new_root = Metadata[Root].from_bytes(data)
new_root: Metadata[Root] = Metadata[Root].from_bytes(data)
except DeserializationError as e:
raise exceptions.RepositoryError("Failed to load root") from e

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

try:
new_timestamp = Metadata[Timestamp].from_bytes(data)
new_timestamp: Metadata[Timestamp] = Metadata[Timestamp].from_bytes(
data
)
except DeserializationError as e:
raise exceptions.RepositoryError("Failed to load timestamp") from e

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

try:
new_snapshot = Metadata[Snapshot].from_bytes(data)
new_snapshot: Metadata[Snapshot] = Metadata[Snapshot].from_bytes(
data
)
except DeserializationError as e:
raise exceptions.RepositoryError("Failed to load snapshot") from e

Expand Down Expand Up @@ -429,7 +433,7 @@ def update_delegated_targets(
) from e

try:
new_delegate = Metadata[Targets].from_bytes(data)
new_delegate: Metadata[Targets] = Metadata[Targets].from_bytes(data)
except DeserializationError as e:
raise exceptions.RepositoryError("Failed to load snapshot") from e

Expand Down

0 comments on commit 871f68c

Please sign in to comment.