28
28
from collections import OrderedDict
29
29
from datetime import datetime , timedelta
30
30
from pathlib import Path
31
+ from typing import Any , Dict
31
32
32
33
from securesystemslib .keys import generate_ed25519_key
33
34
from securesystemslib .signer import SSlibSigner
48
49
from tuf .api .serialization .json import JSONSerializer
49
50
50
51
51
- def _in (days ) :
52
+ def _in (days : float ) -> datetime :
52
53
"""Adds 'days' to now and returns datetime object w/o microseconds."""
53
54
return datetime .utcnow ().replace (microsecond = 0 ) + timedelta (days = days )
54
55
@@ -89,8 +90,8 @@ def _in(days):
89
90
90
91
# Define containers for role objects and cryptographic keys created below. This
91
92
# allows us to sign and write metadata in a batch more easily.
92
- roles = {}
93
- keys = {}
93
+ roles : Dict [ str , Metadata ] = {}
94
+ keys : Dict [ str , Dict [ str , Any ]] = {}
94
95
95
96
96
97
# Targets (integrity)
@@ -117,7 +118,7 @@ def _in(days):
117
118
local_path = Path (__file__ ).resolve ()
118
119
target_path = f"{ local_path .parts [- 2 ]} /{ local_path .parts [- 1 ]} "
119
120
120
- target_file_info = TargetFile .from_file (target_path , local_path )
121
+ target_file_info = TargetFile .from_file (target_path , str ( local_path ) )
121
122
roles ["targets" ].signed .targets [target_path ] = target_file_info
122
123
123
124
# Snapshot (consistency)
@@ -332,7 +333,7 @@ def _in(days):
332
333
del roles ["targets" ].signed .targets [target_path ]
333
334
334
335
# Increase expiry (delegators should be less volatile)
335
- roles ["targets" ].expires = _in (365 )
336
+ roles ["targets" ].signed . expires = _in (365 )
336
337
337
338
338
339
# Snapshot + Timestamp + Sign + Persist
0 commit comments