99from  typing  import  Dict , List , Optional , Sequence , Type , Union 
1010
1111import  executorch .devtools .bundled_program .schema  as  bp_schema 
12- from  pyre_extensions  import  none_throws 
13- 
1412import  executorch .exir .schema  as  core_schema 
1513
1614import  torch 
@@ -44,10 +42,12 @@ class BundledProgram:
4442
4543    def  __init__ (
4644        self ,
47-         executorch_program : Optional [Union [
48-             ExecutorchProgram ,
49-             ExecutorchProgramManager ,
50-         ]],
45+         executorch_program : Optional [
46+             Union [
47+                 ExecutorchProgram ,
48+                 ExecutorchProgramManager ,
49+             ]
50+         ],
5151        method_test_suites : Sequence [MethodTestSuite ],
5252        pte_file_path : Optional [str ] =  None ,
5353    ):
@@ -59,18 +59,24 @@ def __init__(
5959            pte_file_path: The path to pte file to deserialize program if executorch_program is not provided. 
6060        """ 
6161        if  not  executorch_program  and  not  pte_file_path :
62-             raise  RuntimeError ("Either executorch_program or pte_file_path must be provided" )
62+             raise  RuntimeError (
63+                 "Either executorch_program or pte_file_path must be provided" 
64+             )
6365
6466        if  executorch_program  and  pte_file_path :
65-             raise  RuntimeError ("Only one of executorch_program or pte_file_path can be used" )
67+             raise  RuntimeError (
68+                 "Only one of executorch_program or pte_file_path can be used" 
69+             )
6670
6771        method_test_suites  =  sorted (method_test_suites , key = lambda  x : x .method_name )
6872        if  executorch_program :
6973            self ._assert_valid_bundle (executorch_program , method_test_suites )
70-         self .executorch_program : Optional [Union [
71-             ExecutorchProgram ,
72-             ExecutorchProgramManager ,
73-         ]] =  executorch_program 
74+         self .executorch_program : Optional [
75+             Union [
76+                 ExecutorchProgram ,
77+                 ExecutorchProgramManager ,
78+             ]
79+         ] =  executorch_program 
7480        self ._pte_file_path : Optional [str ] =  pte_file_path 
7581
7682        self .method_test_suites  =  method_test_suites 
@@ -88,7 +94,8 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
8894        if  self .executorch_program :
8995            program  =  self ._extract_program (self .executorch_program )
9096        else :
91-             with  open (none_throws (self ._pte_file_path ), "rb" ) as  f :
97+             assert  self ._pte_file_path  is  not   None 
98+             with  open (self ._pte_file_path , "rb" ) as  f :
9299                p_bytes  =  f .read ()
93100            program  =  _deserialize_pte_binary (p_bytes )
94101
0 commit comments