Skip to content

Commit 20490d1

Browse files
QwlouseThe kauldron Authors
authored andcommitted
Internal
PiperOrigin-RevId: 886119476
1 parent 9d5da5e commit 20490d1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

kauldron/konfig/configdict_proxy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,20 @@ def import_qualname(qualname_str: str) -> Callable[..., Any]:
278278
case _:
279279
raise ValueError(f'Invalid {qualname_str!r}')
280280

281-
obj = importlib.import_module(import_str)
281+
try:
282+
obj = importlib.import_module(import_str)
283+
except ModuleNotFoundError as e:
284+
_maybe_add_hint(e, import_str)
285+
raise
282286
for attr in attributes.split('.'):
283287
obj = getattr(obj, attr)
284288
return obj # pytype: disable=bad-return-type
285289

286290

291+
def _maybe_add_hint(exc: ModuleNotFoundError, import_str: str):
292+
pass # No used exeternally.
293+
294+
287295
def num_args(obj: Mapping[str, Any]) -> int:
288296
"""Returns the number of positional arguments of the callable."""
289297
for arg_id in itertools.count():

kauldron/konfig/configdict_proxy_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import json
1919
import pathlib
2020
import types
21+
from unittest import mock
2122

2223
from etils import epy
2324
from kauldron import konfig

0 commit comments

Comments
 (0)