mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-27 22:37:46 +00:00
update pydantic namespace
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
def _raise_import_error() -> None:
|
def _raise_import_error() -> None:
|
||||||
"""Raise ImportError with a helpful message."""
|
"""Raise ImportError with a helpful message."""
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please do not import from langchain_core.pydantic_v1.*."
|
"Please do not import from langchain_core.pydantic_v1. "
|
||||||
"This module was a compatibility shim for pydantic v1, and should "
|
"This module was a compatibility shim for pydantic v1, and should "
|
||||||
"no longer be used "
|
"no longer be used "
|
||||||
"Please update the code to import from Pydantic directly. "
|
"Please update the code to import from Pydantic directly. "
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
def _raise_import_error() -> None:
|
def _raise_import_error() -> None:
|
||||||
"""Raise ImportError with a helpful message."""
|
"""Raise ImportError with a helpful message."""
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please do not import from langchain_core.pydantic_v1.*."
|
"Please do not import from langchain_core.pydantic_v1. "
|
||||||
"This module was a compatibility shim for pydantic v1, and should "
|
"This module was a compatibility shim for pydantic v1, and should "
|
||||||
"no longer be used "
|
"no longer be used "
|
||||||
"Please update the code to import from Pydantic directly. "
|
"Please update the code to import from Pydantic directly. "
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
def _raise_import_error() -> None:
|
def _raise_import_error() -> None:
|
||||||
"""Raise ImportError with a helpful message."""
|
"""Raise ImportError with a helpful message."""
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please do not import from langchain_core.pydantic_v1.*."
|
"Please do not import from langchain_core.pydantic_v1. "
|
||||||
"This module was a compatibility shim for pydantic v1, and should "
|
"This module was a compatibility shim for pydantic v1, and should "
|
||||||
"no longer be used "
|
"no longer be used "
|
||||||
"Please update the code to import from Pydantic directly. "
|
"Please update the code to import from Pydantic directly. "
|
||||||
|
@@ -12,6 +12,8 @@ def test_importable_all() -> None:
|
|||||||
if relative_path.endswith(".typed"):
|
if relative_path.endswith(".typed"):
|
||||||
continue
|
continue
|
||||||
module_name = relative_path.split(".")[0]
|
module_name = relative_path.split(".")[0]
|
||||||
|
if module_name.startswith("pydantic_v1"):
|
||||||
|
continue
|
||||||
module = importlib.import_module("langchain_core." + module_name)
|
module = importlib.import_module("langchain_core." + module_name)
|
||||||
all_ = getattr(module, "__all__", [])
|
all_ = getattr(module, "__all__", [])
|
||||||
for cls_ in all_:
|
for cls_ in all_:
|
||||||
@@ -42,6 +44,10 @@ def test_importable_all_via_subprocess() -> None:
|
|||||||
relative_path = Path(path).parts[-1]
|
relative_path = Path(path).parts[-1]
|
||||||
if relative_path.endswith(".typed"):
|
if relative_path.endswith(".typed"):
|
||||||
continue
|
continue
|
||||||
|
# pydantic_v1 has been deprecated and intentionally
|
||||||
|
# raises an ImportError when imported.
|
||||||
|
if relative_path.startswith("pydantic_v1"):
|
||||||
|
continue
|
||||||
module_name = relative_path.split(".")[0]
|
module_name = relative_path.split(".")[0]
|
||||||
module_names.append(module_name)
|
module_names.append(module_name)
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
def _raise_import_error() -> None:
|
def _raise_import_error() -> None:
|
||||||
"""Raise ImportError with a helpful message."""
|
"""Raise ImportError with a helpful message."""
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please do not import from langchain.pydantic_v1.*."
|
"Please do not import from langchain.pydantic_v1. "
|
||||||
"This module was a compatibility shim for pydantic v1, and should "
|
"This module was a compatibility shim for pydantic v1, and should "
|
||||||
"no longer be used "
|
"no longer be used "
|
||||||
"Please update the code to import from Pydantic directly. "
|
"Please update the code to import from Pydantic directly. "
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
def _raise_import_error() -> None:
|
def _raise_import_error() -> None:
|
||||||
"""Raise ImportError with a helpful message."""
|
"""Raise ImportError with a helpful message."""
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please do not import from langchain.pydantic_v1.*."
|
"Please do not import from langchain.pydantic_v1. "
|
||||||
"This module was a compatibility shim for pydantic v1, and should "
|
"This module was a compatibility shim for pydantic v1, and should "
|
||||||
"no longer be used "
|
"no longer be used "
|
||||||
"Please update the code to import from Pydantic directly. "
|
"Please update the code to import from Pydantic directly. "
|
||||||
|
@@ -24,6 +24,11 @@ def test_import_all() -> None:
|
|||||||
# Without init
|
# Without init
|
||||||
module_name = module_name.rsplit(".", 1)[0]
|
module_name = module_name.rsplit(".", 1)[0]
|
||||||
|
|
||||||
|
# pydantic_v1 name space is deprecated and will intentionally raise an
|
||||||
|
# ImportError
|
||||||
|
if module_name.startswith("langchain.pydantic_v1"):
|
||||||
|
continue
|
||||||
|
|
||||||
mod = importlib.import_module(module_name)
|
mod = importlib.import_module(module_name)
|
||||||
|
|
||||||
all = getattr(mod, "__all__", [])
|
all = getattr(mod, "__all__", [])
|
||||||
@@ -61,6 +66,11 @@ def test_import_all_using_dir() -> None:
|
|||||||
if module_name.startswith("langchain_community.") and COMMUNITY_NOT_INSTALLED:
|
if module_name.startswith("langchain_community.") and COMMUNITY_NOT_INSTALLED:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# pydantic_v1 name space is deprecated and will intentionally raise an
|
||||||
|
# ImportError
|
||||||
|
if module_name.startswith("langchain.pydantic_v1"):
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mod = importlib.import_module(module_name)
|
mod = importlib.import_module(module_name)
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
|
Reference in New Issue
Block a user