Skip to content

Commit

Permalink
[Typing][B-56] Add type annotations for python/paddle/utils/lazy_imp…
Browse files Browse the repository at this point in the history
…ort.py (#65822)
  • Loading branch information
megemini authored Jul 10, 2024
1 parent 88c6848 commit 900d27c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/paddle/utils/lazy_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 900d27c

Please sign in to comment.