From 900d27c40ef4567d7ea6342f3f0eedd394885ecb Mon Sep 17 00:00:00 2001 From: megemini Date: Wed, 10 Jul 2024 20:19:16 +0800 Subject: [PATCH] [Typing][B-56] Add type annotations for python/paddle/utils/lazy_import.py (#65822) --- python/paddle/utils/lazy_import.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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