diff --git a/python/paddle/utils/lazy_import.py b/python/paddle/utils/lazy_import.py index 398951585417a2..a1db581a31c7d1 100644 --- a/python/paddle/utils/lazy_import.py +++ b/python/paddle/utils/lazy_import.py @@ -13,12 +13,19 @@ # limitations under the License. """Lazy imports for heavy dependencies.""" +from __future__ import annotations + import importlib +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from types import ModuleType + __all__ = [] -def try_import(module_name, err_msg=None): +def try_import(module_name: str, err_msg: str | None = None) -> ModuleType: """Try importing a module, with an informative error message on failure.""" install_name = module_name