Skip to content

Commit d03866f

Browse files
tarun292facebook-github-bot
authored andcommitted
Remove none_throws usage from bundled_program (#7296)
Summary: Was added in D67013542. Reviewed By: lucylq Differential Revision: D67123067
1 parent 957259e commit d03866f

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

devtools/bundled_program/core.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from typing import Dict, List, Optional, Sequence, Type, Union
1010

1111
import executorch.devtools.bundled_program.schema as bp_schema
12-
from pyre_extensions import none_throws
1312

1413
import executorch.exir.schema as core_schema
1514

@@ -44,10 +43,12 @@ class BundledProgram:
4443

4544
def __init__(
4645
self,
47-
executorch_program: Optional[Union[
48-
ExecutorchProgram,
49-
ExecutorchProgramManager,
50-
]],
46+
executorch_program: Optional[
47+
Union[
48+
ExecutorchProgram,
49+
ExecutorchProgramManager,
50+
]
51+
],
5152
method_test_suites: Sequence[MethodTestSuite],
5253
pte_file_path: Optional[str] = None,
5354
):
@@ -59,18 +60,24 @@ def __init__(
5960
pte_file_path: The path to pte file to deserialize program if executorch_program is not provided.
6061
"""
6162
if not executorch_program and not pte_file_path:
62-
raise RuntimeError("Either executorch_program or pte_file_path must be provided")
63+
raise RuntimeError(
64+
"Either executorch_program or pte_file_path must be provided"
65+
)
6366

6467
if executorch_program and pte_file_path:
65-
raise RuntimeError("Only one of executorch_program or pte_file_path can be used")
68+
raise RuntimeError(
69+
"Only one of executorch_program or pte_file_path can be used"
70+
)
6671

6772
method_test_suites = sorted(method_test_suites, key=lambda x: x.method_name)
6873
if executorch_program:
6974
self._assert_valid_bundle(executorch_program, method_test_suites)
70-
self.executorch_program: Optional[Union[
71-
ExecutorchProgram,
72-
ExecutorchProgramManager,
73-
]] = executorch_program
75+
self.executorch_program: Optional[
76+
Union[
77+
ExecutorchProgram,
78+
ExecutorchProgramManager,
79+
]
80+
] = executorch_program
7481
self._pte_file_path: Optional[str] = pte_file_path
7582

7683
self.method_test_suites = method_test_suites
@@ -88,7 +95,8 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
8895
if self.executorch_program:
8996
program = self._extract_program(self.executorch_program)
9097
else:
91-
with open(none_throws(self._pte_file_path), "rb") as f:
98+
assert self._pte_file_path is not None
99+
with open(self._pte_file_path, "rb") as f:
92100
p_bytes = f.read()
93101
program = _deserialize_pte_binary(p_bytes)
94102

0 commit comments

Comments
 (0)