Skip to content

Commit f185df5

Browse files
committed
Use assert to check for None values
This is done only for hinting 'mypy' that we have ensured these values cannot be None. 'Bandit' raises warnings for assert usage in the code but we are disabling them since we do not rely upon 'asserts' for any runtime checks but only for type checking. Signed-off-by: Teodora Sechkova <[email protected]>
1 parent 9f4d39f commit f185df5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tuf/ngclient/updater.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def _load_snapshot(self) -> None:
336336
# Local snapshot does not exist or is invalid: update from remote
337337
logger.debug("Failed to load local snapshot %s", e)
338338

339+
assert self._trusted_set.timestamp is not None # nosec
339340
metainfo = self._trusted_set.timestamp.signed.meta["snapshot.json"]
340341
length = metainfo.length or self.config.snapshot_max_length
341342
version = None
@@ -356,6 +357,7 @@ def _load_targets(self, role: str, parent_role: str) -> None:
356357
# Local 'role' does not exist or is invalid: update from remote
357358
logger.debug("Failed to load local %s: %s", role, e)
358359

360+
assert self._trusted_set.snapshot is not None # nosec
359361
metainfo = self._trusted_set.snapshot.signed.meta[f"{role}.json"]
360362
length = metainfo.length or self.config.targets_max_length
361363
version = None

0 commit comments

Comments
 (0)