@@ -80,6 +80,7 @@ def executable_exists(args: List) -> bool:
8080
8181
8282def _idf_version_from_cmake () -> Optional [str ]:
83+ """Acquires version of ESP-IDF from version.cmake"""
8384 version_path = os .path .join (os .environ ['IDF_PATH' ], 'tools/cmake/version.cmake' )
8485 regex = re .compile (r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)' )
8586 ver = {}
@@ -113,7 +114,7 @@ def idf_version() -> Optional[str]:
113114 '--work-tree=%s' % os .environ ['IDF_PATH' ],
114115 'describe' , '--tags' , '--dirty' , '--match' , 'v*.*' ,
115116 ]).decode ('utf-8' , 'ignore' ).strip ()
116- except ( subprocess . CalledProcessError , UnicodeError ) :
117+ except Exception :
117118 # if failed, then try to parse cmake.version file
118119 sys .stderr .write ('WARNING: Git version unavailable, reading from source\n ' )
119120 version = _idf_version_from_cmake ()
@@ -148,7 +149,7 @@ def get_default_serial_port() -> Any:
148149
149150# function prints warning when autocompletion is not being performed
150151# set argument stream to sys.stderr for errors and exceptions
151- def print_warning (message : str , stream : TextIO = None ) -> None :
152+ def print_warning (message : str , stream : Optional [ TextIO ] = None ) -> None :
152153 if not SHELL_COMPLETE_RUN :
153154 print (message , file = stream or sys .stderr )
154155
@@ -277,8 +278,9 @@ def fit_text_in_terminal(out: str) -> str:
277278
278279
279280class RunTool :
280- def __init__ (self , tool_name : str , args : List , cwd : str , env : Dict = None , custom_error_handler : FunctionType = None , build_dir : str = None ,
281- hints : bool = True , force_progression : bool = False , interactive : bool = False , convert_output : bool = False ) -> None :
281+ def __init__ (self , tool_name : str , args : List , cwd : str , env : Optional [Dict ]= None , custom_error_handler : Optional [FunctionType ]= None ,
282+ build_dir : Optional [str ]= None , hints : bool = True , force_progression : bool = False , interactive : bool = False , convert_output : bool = False
283+ ) -> None :
282284 self .tool_name = tool_name
283285 self .args = args
284286 self .cwd = cwd
@@ -471,7 +473,7 @@ def run_tool(*args: Any, **kwargs: Any) -> None:
471473
472474
473475def run_target (target_name : str , args : 'PropertyDict' , env : Optional [Dict ]= None ,
474- custom_error_handler : FunctionType = None , force_progression : bool = False , interactive : bool = False ) -> None :
476+ custom_error_handler : Optional [ FunctionType ] = None , force_progression : bool = False , interactive : bool = False ) -> None :
475477 """Run target in build directory."""
476478 if env is None :
477479 env = {}
@@ -554,7 +556,7 @@ def _detect_cmake_generator(prog_name: str) -> Any:
554556
555557
556558def ensure_build_directory (args : 'PropertyDict' , prog_name : str , always_run_cmake : bool = False ,
557- env : Dict = None ) -> None :
559+ env : Optional [ Dict ] = None ) -> None :
558560 """Check the build directory exists and that cmake has been run there.
559561
560562 If this isn't the case, create the build directory (if necessary) and
@@ -671,7 +673,7 @@ def merge_action_lists(*action_lists: Dict) -> Dict:
671673 return merged_actions
672674
673675
674- def get_sdkconfig_filename (args : 'PropertyDict' , cache_cmdl : Dict = None ) -> str :
676+ def get_sdkconfig_filename (args : 'PropertyDict' , cache_cmdl : Optional [ Dict ] = None ) -> str :
675677 """
676678 Get project's sdkconfig file name.
677679 """
@@ -720,7 +722,7 @@ def is_target_supported(project_path: str, supported_targets: List) -> bool:
720722
721723
722724def _check_idf_target (args : 'PropertyDict' , prog_name : str , cache : Dict ,
723- cache_cmdl : Dict , env : Dict = None ) -> None :
725+ cache_cmdl : Dict , env : Optional [ Dict ] = None ) -> None :
724726 """
725727 Cross-check the three settings (sdkconfig, CMakeCache, environment) and if there is
726728 mismatch, fail with instructions on how to fix this.
0 commit comments