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 (
1617 download ,
1718 requests_fetcher ,
@@ -93,7 +94,9 @@ def refresh(self) -> None:
9394 self ._load_snapshot ()
9495 self ._load_targets ("targets" , "root" )
9596
96- def get_one_valid_targetinfo (self , target_path : str ) -> Dict :
97+ def get_one_valid_targetinfo (
98+ self , target_path : str
99+ ) -> Union [Dict [str , Any ], None ]:
97100 """
98101 Returns the target information for a target identified by target_path.
99102
@@ -312,7 +315,9 @@ def _load_targets(self, role: str, parent_role: str) -> None:
312315 self ._trusted_set .update_delegated_targets (data , role , parent_role )
313316 self ._persist_metadata (role , data )
314317
315- def _preorder_depth_first_walk (self , target_filepath : str ) -> Dict :
318+ def _preorder_depth_first_walk (
319+ self , target_filepath : str
320+ ) -> Union [Dict [str , Any ], None ]:
316321 """
317322 Interrogates the tree of target delegations in order of appearance
318323 (which implicitly order trustworthiness), and returns the matching
@@ -338,7 +343,7 @@ def _preorder_depth_first_walk(self, target_filepath: str) -> Dict:
338343 # its targets, delegations, and child roles can be inspected.
339344 self ._load_targets (role_name , parent_role )
340345
341- role_metadata = self ._trusted_set [role_name ].signed
346+ role_metadata : Targets = self ._trusted_set [role_name ].signed
342347 target = role_metadata .targets .get (target_filepath )
343348
344349 if target is not None :
0 commit comments