Skip to content

Commit 900d27c

Browse files
authored
[Typing][B-56] Add type annotations for python/paddle/utils/lazy_import.py (#65822)
1 parent 88c6848 commit 900d27c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/paddle/utils/lazy_import.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313
# limitations under the License.
1414
"""Lazy imports for heavy dependencies."""
1515

16+
from __future__ import annotations
17+
1618
import importlib
19+
from typing import TYPE_CHECKING
20+
21+
if TYPE_CHECKING:
22+
from types import ModuleType
23+
1724

1825
__all__ = []
1926

2027

21-
def try_import(module_name, err_msg=None):
28+
def try_import(module_name: str, err_msg: str | None = None) -> ModuleType:
2229
"""Try importing a module, with an informative error message on failure."""
2330
install_name = module_name
2431

0 commit comments

Comments
 (0)