66
77import logging
88import os
9- from typing import Any , Dict , List , Optional
9+ from typing import Any , Dict , List , Optional , Union
1010from urllib import parse
1111
1212from securesystemslib import util as sslib_util
1313
1414from tuf import exceptions
15+ from tuf .api .metadata import Targets
1516from tuf .ngclient ._internal import requests_fetcher , trusted_metadata_set
1617from tuf .ngclient .config import UpdaterConfig
1718from tuf .ngclient .fetcher import FetcherInterface
@@ -89,7 +90,9 @@ def refresh(self) -> None:
8990 self ._load_snapshot ()
9091 self ._load_targets ("targets" , "root" )
9192
92- def get_one_valid_targetinfo (self , target_path : str ) -> Dict :
93+ def get_one_valid_targetinfo (
94+ self , target_path : str
95+ ) -> Union [Dict [str , Any ], None ]:
9396 """
9497 Returns the target information for a target identified by target_path.
9598
@@ -303,7 +306,9 @@ def _load_targets(self, role: str, parent_role: str) -> None:
303306 self ._trusted_set .update_delegated_targets (data , role , parent_role )
304307 self ._persist_metadata (role , data )
305308
306- def _preorder_depth_first_walk (self , target_filepath : str ) -> Dict :
309+ def _preorder_depth_first_walk (
310+ self , target_filepath : str
311+ ) -> Union [Dict [str , Any ], None ]:
307312 """
308313 Interrogates the tree of target delegations in order of appearance
309314 (which implicitly order trustworthiness), and returns the matching
@@ -329,7 +334,7 @@ def _preorder_depth_first_walk(self, target_filepath: str) -> Dict:
329334 # its targets, delegations, and child roles can be inspected.
330335 self ._load_targets (role_name , parent_role )
331336
332- role_metadata = self ._trusted_set [role_name ].signed
337+ role_metadata : Targets = self ._trusted_set [role_name ].signed
333338 target = role_metadata .targets .get (target_filepath )
334339
335340 if target is not None :
0 commit comments