diff --git a/mindspore/python/mindspore/_extends/parse/parser.py b/mindspore/python/mindspore/_extends/parse/parser.py index 1e49ab0ed0f..92305920ae3 100644 --- a/mindspore/python/mindspore/_extends/parse/parser.py +++ b/mindspore/python/mindspore/_extends/parse/parser.py @@ -168,6 +168,8 @@ def get_env_support_modules(): except (ModuleNotFoundError, ValueError): module = module[0:module.rfind('.')] module_spec = importlib.util.find_spec(module) + finally: + pass if module_spec is None: raise ModuleNotFoundError(f"Cannot find module: {module}. " \ f"Please check if {module} is installed, or if MS_DEV_SUPPORT_MODULES is set correctly.") @@ -654,7 +656,7 @@ def eval_script(exp_str, params): # Convert set to tuple. if isinstance(obj, set): - obj = tuple(obj) + return tuple(obj) return obj @@ -683,6 +685,14 @@ class Parser: self.function_name = fn.__name__ self.col_offset = 0 + @staticmethod + def is_unsupported_special_type(value): + """To check if not supported special type, such as print""" + if value in _unsupported_special_type: + logger.debug(f"Found unsupported special type: '{value}'.") + return True + return False + def parse(self): """Parse the function or method.""" logger.debug("fn: %r", self.fn) @@ -747,13 +757,6 @@ class Parser: return True return False - def is_unsupported_special_type(self, value): - """To check if not supported special type, such as print""" - if value in _unsupported_special_type: - logger.debug(f"Found unsupported special type: '{value}'.") - return True - return False - def get_namespace_symbol(self, var: str): """Get symbol type and namespace and symbol.""" if var in self.closure_namespace: diff --git a/mindspore/python/mindspore/_extends/parse/standard_method.py b/mindspore/python/mindspore/_extends/parse/standard_method.py index df9792c4a2e..675c0282d0e 100644 --- a/mindspore/python/mindspore/_extends/parse/standard_method.py +++ b/mindspore/python/mindspore/_extends/parse/standard_method.py @@ -1608,6 +1608,7 @@ def csr_to_dense(x): @constexpr def empty_tensor(dtype): + """Return empty tensor""" return Tensor([], dtype) @@ -1883,6 +1884,7 @@ def list_append(self_, item): def list_insert(self_, index, obj): + """Insert into list""" return _insert(self_, index, obj) #################