Skip to content

Commit 0f94c03

Browse files
committed
repository: Handle linting issues
Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 69cb140 commit 0f94c03

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

examples/repository/_simplerepo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def __init__(self) -> None:
6161
self.target_cache: Dict[str, bytes] = {}
6262
# version cache for snapshot and all targets, updated in close()
6363
self._snapshot_info = MetaFile(1)
64-
self._targets_infos = defaultdict(lambda: MetaFile(1))
64+
self._targets_infos: Dict[str, MetaFile] = defaultdict(
65+
lambda: MetaFile(1)
66+
)
6567

6668
# setup a basic repository, generate signing key per top-level role
6769
with self.edit("root", init=True) as root:

tuf/repository/_repository.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
"""Repository Abstraction for metadata management"""
55

6-
from copy import deepcopy
76
import logging
87
from abc import ABC, abstractmethod
98
from contextlib import contextmanager, suppress
9+
from copy import deepcopy
1010
from typing import Dict, Generator, Optional, Tuple
1111

1212
from tuf.api.metadata import Metadata, MetaFile, Signed
@@ -132,7 +132,8 @@ def snapshot(self, force: bool = False) -> Tuple[bool, Dict[str, MetaFile]]:
132132
raise AbortEdit("Skip snapshot: No targets version changes")
133133

134134
if not update_version:
135-
logger.debug("Snapshot update not needed")
135+
# this is reachable as edit() handles AbortEdit
136+
logger.debug("Snapshot update not needed") # type: ignore[unreachable]
136137
else:
137138
logger.debug(
138139
"Snapshot v%d, %d targets", snapshot.version, len(snapshot.meta)
@@ -153,7 +154,7 @@ def timestamp(self, force: bool = False) -> Tuple[bool, Optional[MetaFile]]:
153154
removed = None
154155
with self.edit("timestamp") as timestamp:
155156
if self.snapshot_info.version < timestamp.snapshot_meta.version:
156-
raise ValueError(f"snapshot version rollback")
157+
raise ValueError("snapshot version rollback")
157158

158159
if self.snapshot_info.version > timestamp.snapshot_meta.version:
159160
update_version = True
@@ -164,7 +165,8 @@ def timestamp(self, force: bool = False) -> Tuple[bool, Optional[MetaFile]]:
164165
raise AbortEdit("Skip timestamp: No snapshot version changes")
165166

166167
if not update_version:
167-
logger.debug("Timestamp update not needed")
168+
# this is reachable as edit() handles AbortEdit
169+
logger.debug("Timestamp update not needed") # type: ignore[unreachable]
168170
else:
169171
logger.debug("Timestamp v%d", timestamp.version)
170172
return update_version, removed

0 commit comments

Comments
 (0)