Skip to content

Commit 772b5cc

Browse files
committed
fix tests
1 parent e27b4b3 commit 772b5cc

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

libs/core/langchain_core/_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"LangChainDeprecationWarning": "deprecation",
5454
"deprecated": "deprecation",
5555
"surface_langchain_deprecation_warnings": "deprecation",
56-
"suppress_langchain_deprecation_warnings": "deprecation",
56+
"suppress_langchain_deprecation_warning": "deprecation",
5757
"warn_deprecated": "deprecation",
5858
}
5959

libs/core/langchain_core/_lazy_imports.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,15 @@ def create_dynamic_getattr(
1717

1818
def _dynamic_getattr(attr_name: str) -> object:
1919
module_name = dynamic_imports.get(attr_name)
20-
if module_name is None:
21-
import_error_msg = (
22-
f"cannot import name '{attr_name}' from '{package_name}.{module_path}'"
23-
)
24-
raise ImportError(import_error_msg)
2520

26-
if module_name == "__module__":
27-
attr = import_module(f".{module_path}.{attr_name}", package=package_name)
28-
globals()[attr_name] = attr
29-
return attr
21+
if module_name == "__module__" or module_name is None:
22+
module = import_module(f".{module_path}.{attr_name}", package=package_name)
23+
globals()[attr_name] = module
24+
return module
3025

3126
module = import_module(f".{module_path}.{module_name}", package=package_name)
3227
attr = getattr(module, attr_name)
33-
34-
g = globals()
35-
g[attr_name] = attr
28+
globals()[attr_name] = attr
3629

3730
# TODO: determine if we want to do this eagerly
3831
# for k, v_module_name in dynamic_imports.items():

libs/core/tests/benchmarks/test_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
),
2323
pytest.param(
2424
"from langchain_core.prompts import ChatPromptTemplate",
25-
id="PromChatPromptTemplateptTemplate",
25+
id="ChatPromptTemplate",
2626
),
2727
pytest.param("from langchain_core.documents import Document", id="Document"),
2828
pytest.param(

0 commit comments

Comments
 (0)