1818TMP_MPY_SCRIPT = "_tmp.mpy"
1919
2020
21- def make_build_dir ():
21+ def make_build_dir () -> None :
2222 # Create build folder if it does not exist
2323 if not os .path .exists (BUILD_DIR ):
2424 os .mkdir (BUILD_DIR )
@@ -30,7 +30,7 @@ def make_build_dir():
3030
3131async def compile_file (
3232 proj_dir : str , proj_path : str , abi : int , compile_args : list [str ] | None = None
33- ):
33+ ) -> bytes :
3434 """Compiles a Python file with ``mpy-cross``.
3535
3636 Arguments:
@@ -77,10 +77,12 @@ async def compile_file(
7777
7878 proc .check_returncode ()
7979
80+ assert mpy is not None , "if process succeeded, mpy should not be None"
81+
8082 return mpy
8183
8284
83- async def compile_multi_file (path : str , abi : int | tuple [int , int ]):
85+ async def compile_multi_file (path : str , abi : int | tuple [int , int ]) -> bytes :
8486 """Compiles a Python file and its dependencies with ``mpy-cross``.
8587
8688 On the hub, all dependencies behave as independent modules. Any (leading)
@@ -178,7 +180,7 @@ async def compile_multi_file(path: str, abi: int | tuple[int, int]):
178180 return b"" .join (parts )
179181
180182
181- def save_script (py_string ) :
183+ def save_script (py_string : str ) -> str :
182184 """Save a MicroPython one-liner to a file."""
183185 # Make the build directory.
184186 make_build_dir ()
@@ -195,7 +197,7 @@ def save_script(py_string):
195197 return py_path
196198
197199
198- def print_mpy (data ) :
200+ def print_mpy (data : bytes ) -> None :
199201 # Print as string as a sanity check.
200202 print ()
201203 print ("Bytes:" )
0 commit comments