Skip to content

Commit 122c522

Browse files
committed
repository: Use new annotated properties in do_*()
This gives us working annotations in do_timestamp() and do_snapshot(). Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
1 parent 75ca67e commit 122c522

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

tuf/repository/_repository.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def close(self, role: str, md: Metadata) -> None:
6565
def targets_infos(self) -> Dict[str, MetaFile]:
6666
"""Returns the MetaFiles for current targets metadatas
6767
68-
This property is used by snapshot() to update Snapshot.meta: Repository
69-
implementations should override this property to enable snapshot().
68+
This property is used by do_snapshot() to update Snapshot.meta:
69+
Repository implementations should override this property to enable
70+
do_snapshot().
7071
7172
Note that there is a difference between this return value and
7273
Snapshot.meta: This dictionary reflects the targets metadata that
@@ -79,9 +80,9 @@ def targets_infos(self) -> Dict[str, MetaFile]:
7980
def snapshot_info(self) -> MetaFile:
8081
"""Returns the MetaFile for current snapshot metadata
8182
82-
This property is used by timestamp() to update Timestamp.meta:
83+
This property is used by do_timestamp() to update Timestamp.meta:
8384
Repository implementations should override this property to enable
84-
timestamp().
85+
do_timestamp().
8586
"""
8687
raise NotImplementedError
8788

@@ -187,7 +188,7 @@ def do_snapshot(
187188
update_version = force
188189
removed: Dict[str, MetaFile] = {}
189190

190-
with self.edit("snapshot") as snapshot:
191+
with self.edit_snapshot() as snapshot:
191192
for keyname, new_meta in self.targets_infos.items():
192193
if keyname not in snapshot.meta:
193194
update_version = True
@@ -203,11 +204,11 @@ def do_snapshot(
203204
removed[keyname] = old_meta
204205

205206
if not update_version:
206-
# prevent edit() from storing a new snapshot version
207+
# prevent edit_snapshot() from storing a new version
207208
raise AbortEdit("Skip snapshot: No targets version changes")
208209

209210
if not update_version:
210-
# this is reachable as edit() handles AbortEdit
211+
# this is reachable as edit_snapshot() handles AbortEdit
211212
logger.debug("Snapshot update not needed") # type: ignore[unreachable]
212213
else:
213214
logger.debug("Snapshot v%d", snapshot.version)
@@ -227,7 +228,7 @@ def do_timestamp(
227228
"""
228229
update_version = force
229230
removed = None
230-
with self.edit("timestamp") as timestamp:
231+
with self.edit_timestamp() as timestamp:
231232
if self.snapshot_info.version < timestamp.snapshot_meta.version:
232233
raise ValueError("snapshot version rollback")
233234

@@ -240,7 +241,7 @@ def do_timestamp(
240241
raise AbortEdit("Skip timestamp: No snapshot version changes")
241242

242243
if not update_version:
243-
# this is reachable as edit() handles AbortEdit
244+
# this is reachable as edit_timestamp() handles AbortEdit
244245
logger.debug("Timestamp update not needed") # type: ignore[unreachable]
245246
else:
246247
logger.debug("Timestamp v%d", timestamp.version)

0 commit comments

Comments
 (0)