mirror of
https://github.com/hwchase17/langchain.git
synced 2026-08-09 00:38:10 +00:00
fix: remove relative imports (#34680)
standardizing on absolute imports rather than relative across the codebase
This commit is contained in:
@@ -13,20 +13,20 @@ from typing import TYPE_CHECKING
|
||||
from langchain_core._import_utils import import_attr
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .beta_decorator import (
|
||||
from langchain_core._api.beta_decorator import (
|
||||
LangChainBetaWarning,
|
||||
beta,
|
||||
suppress_langchain_beta_warning,
|
||||
surface_langchain_beta_warnings,
|
||||
)
|
||||
from .deprecation import (
|
||||
from langchain_core._api.deprecation import (
|
||||
LangChainDeprecationWarning,
|
||||
deprecated,
|
||||
suppress_langchain_deprecation_warning,
|
||||
surface_langchain_deprecation_warnings,
|
||||
warn_deprecated,
|
||||
)
|
||||
from .path import as_import_path, get_relative_path
|
||||
from langchain_core._api.path import as_import_path, get_relative_path
|
||||
|
||||
__all__ = (
|
||||
"LangChainBetaWarning",
|
||||
|
||||
@@ -30,9 +30,9 @@ from typing import TYPE_CHECKING
|
||||
from langchain_core._import_utils import import_attr
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .base import Document
|
||||
from .compressor import BaseDocumentCompressor
|
||||
from .transformers import BaseDocumentTransformer
|
||||
from langchain_core.documents.base import Document
|
||||
from langchain_core.documents.compressor import BaseDocumentCompressor
|
||||
from langchain_core.documents.transformers import BaseDocumentTransformer
|
||||
|
||||
__all__ = ("BaseDocumentCompressor", "BaseDocumentTransformer", "Document")
|
||||
|
||||
|
||||
@@ -109,6 +109,9 @@ flake8-builtins.ignorelist = ["id", "input", "type"]
|
||||
flake8-type-checking.runtime-evaluated-base-classes = [ "pydantic.BaseModel", "langchain_core.load.serializable.Serializable", "langchain_core.runnables.base.RunnableSerializable", "langchain_core.language_models.base.BaseLanguageModel", "langchain_core.outputs.generation.Generation", "langchain_core.tools.base.BaseTool",]
|
||||
pep8-naming.classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",]
|
||||
|
||||
[tool.ruff.lint.flake8-tidy-imports]
|
||||
ban-relative-imports = "all"
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
ignore-var-parameters = true # ignore missing documentation for *args and **kwargs parameters
|
||||
|
||||
@@ -1,32 +1,29 @@
|
||||
"""Entrypoint to using [middleware](https://docs.langchain.com/oss/python/langchain/middleware) plugins with [Agents](https://docs.langchain.com/oss/python/langchain/agents).""" # noqa: E501
|
||||
|
||||
from .context_editing import (
|
||||
ClearToolUsesEdit,
|
||||
ContextEditingMiddleware,
|
||||
)
|
||||
from .file_search import FilesystemFileSearchMiddleware
|
||||
from .human_in_the_loop import (
|
||||
from langchain.agents.middleware.context_editing import ClearToolUsesEdit, ContextEditingMiddleware
|
||||
from langchain.agents.middleware.file_search import FilesystemFileSearchMiddleware
|
||||
from langchain.agents.middleware.human_in_the_loop import (
|
||||
HumanInTheLoopMiddleware,
|
||||
InterruptOnConfig,
|
||||
)
|
||||
from .model_call_limit import ModelCallLimitMiddleware
|
||||
from .model_fallback import ModelFallbackMiddleware
|
||||
from .model_retry import ModelRetryMiddleware
|
||||
from .pii import PIIDetectionError, PIIMiddleware
|
||||
from .shell_tool import (
|
||||
from langchain.agents.middleware.model_call_limit import ModelCallLimitMiddleware
|
||||
from langchain.agents.middleware.model_fallback import ModelFallbackMiddleware
|
||||
from langchain.agents.middleware.model_retry import ModelRetryMiddleware
|
||||
from langchain.agents.middleware.pii import PIIDetectionError, PIIMiddleware
|
||||
from langchain.agents.middleware.shell_tool import (
|
||||
CodexSandboxExecutionPolicy,
|
||||
DockerExecutionPolicy,
|
||||
HostExecutionPolicy,
|
||||
RedactionRule,
|
||||
ShellToolMiddleware,
|
||||
)
|
||||
from .summarization import SummarizationMiddleware
|
||||
from .todo import TodoListMiddleware
|
||||
from .tool_call_limit import ToolCallLimitMiddleware
|
||||
from .tool_emulator import LLMToolEmulator
|
||||
from .tool_retry import ToolRetryMiddleware
|
||||
from .tool_selection import LLMToolSelectorMiddleware
|
||||
from .types import (
|
||||
from langchain.agents.middleware.summarization import SummarizationMiddleware
|
||||
from langchain.agents.middleware.todo import TodoListMiddleware
|
||||
from langchain.agents.middleware.tool_call_limit import ToolCallLimitMiddleware
|
||||
from langchain.agents.middleware.tool_emulator import LLMToolEmulator
|
||||
from langchain.agents.middleware.tool_retry import ToolRetryMiddleware
|
||||
from langchain.agents.middleware.tool_selection import LLMToolSelectorMiddleware
|
||||
from langchain.agents.middleware.types import (
|
||||
AgentMiddleware,
|
||||
AgentState,
|
||||
ModelRequest,
|
||||
|
||||
@@ -127,6 +127,9 @@ unfixable = [
|
||||
flake8-annotations.allow-star-arg-any = true
|
||||
allowed-confusables = ["–"]
|
||||
|
||||
[tool.ruff.lint.flake8-tidy-imports]
|
||||
ban-relative-imports = "all"
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
ignore-var-parameters = true # ignore missing documentation for *args and **kwargs parameters
|
||||
|
||||
@@ -7,7 +7,7 @@ from langgraph.checkpoint.base import BaseCheckpointSaver
|
||||
from langgraph.store.base import BaseStore
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from .conftest_checkpointer import (
|
||||
from tests.unit_tests.agents.conftest_checkpointer import (
|
||||
_checkpointer_memory,
|
||||
_checkpointer_postgres,
|
||||
_checkpointer_postgres_aio,
|
||||
@@ -18,7 +18,7 @@ from .conftest_checkpointer import (
|
||||
_checkpointer_sqlite,
|
||||
_checkpointer_sqlite_aio,
|
||||
)
|
||||
from .conftest_store import (
|
||||
from tests.unit_tests.agents.conftest_store import (
|
||||
_store_memory,
|
||||
_store_postgres,
|
||||
_store_postgres_aio,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
from contextlib import asynccontextmanager, contextmanager
|
||||
|
||||
from .memory_assert import (
|
||||
MemorySaverAssertImmutable,
|
||||
)
|
||||
from tests.unit_tests.agents.memory_assert import MemorySaverAssertImmutable
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
||||
@@ -11,7 +11,7 @@ from typing import Any
|
||||
|
||||
from langchain_core.messages import HumanMessage, ToolMessage
|
||||
|
||||
from .any_str import AnyStr
|
||||
from tests.unit_tests.agents.any_str import AnyStr
|
||||
|
||||
|
||||
def _AnyIdHumanMessage(**kwargs: Any) -> HumanMessage: # noqa: N802
|
||||
|
||||
@@ -10,8 +10,7 @@ from langchain_core.messages import AIMessage, HumanMessage
|
||||
from langchain_core.tools import tool
|
||||
|
||||
from langchain.agents import create_agent
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
@tool
|
||||
|
||||
@@ -10,8 +10,7 @@ from langgraph.store.memory import InMemoryStore
|
||||
from langchain.agents import AgentState, create_agent
|
||||
from langchain.tools import InjectedState
|
||||
from langchain.tools import tool as dec_tool
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
|
||||
@@ -26,8 +26,7 @@ from langgraph.store.memory import InMemoryStore
|
||||
from langchain.agents import create_agent
|
||||
from langchain.agents.middleware.types import AgentMiddleware, AgentState
|
||||
from langchain.tools import InjectedState, ToolRuntime
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
def test_tool_runtime_basic_injection() -> None:
|
||||
|
||||
@@ -9,8 +9,7 @@ from langchain_core.tools import StructuredTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from langchain.agents import create_agent
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
class ArgsSchema(BaseModel):
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
# _infer_handled_types,
|
||||
# )
|
||||
|
||||
# from .any_str import AnyStr
|
||||
# from .messages import _AnyIdHumanMessage, _AnyIdToolMessage
|
||||
# from .model import FakeToolCallingModel
|
||||
# from tests.unit_tests.agents.any_str import AnyStr
|
||||
# from tests.unit_tests.agents.messages import _AnyIdHumanMessage, _AnyIdToolMessage
|
||||
# from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
# pytestmark = pytest.mark.anyio
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ from langchain_core.tools import tool
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from langchain.agents.factory import create_agent
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
def test_agent_graph_without_return_direct_tools(snapshot: SnapshotAssertion) -> None:
|
||||
|
||||
@@ -17,8 +17,7 @@ from langchain.agents.middleware.types import AgentMiddleware, AgentState
|
||||
# Cannot move ToolRuntime to TYPE_CHECKING as parameters of @tool annotated functions
|
||||
# are inspected at runtime.
|
||||
from langchain.tools import ToolRuntime # noqa: TC001
|
||||
|
||||
from .model import FakeToolCallingModel
|
||||
from tests.unit_tests.agents.model import FakeToolCallingModel
|
||||
|
||||
|
||||
@tool
|
||||
|
||||
2
libs/langchain_v1/uv.lock
generated
2
libs/langchain_v1/uv.lock
generated
@@ -1863,7 +1863,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langchain"
|
||||
version = "1.2.2"
|
||||
version = "1.2.3"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "langchain-core" },
|
||||
|
||||
@@ -19,13 +19,19 @@ modules = [
|
||||
for module in modules:
|
||||
pytest.register_assert_rewrite(f"langchain_tests.integration_tests.{module}")
|
||||
|
||||
from .base_store import BaseStoreAsyncTests, BaseStoreSyncTests
|
||||
from .cache import AsyncCacheTestSuite, SyncCacheTestSuite
|
||||
from .chat_models import ChatModelIntegrationTests
|
||||
from .embeddings import EmbeddingsIntegrationTests
|
||||
from .retrievers import RetrieversIntegrationTests
|
||||
from .tools import ToolsIntegrationTests
|
||||
from .vectorstores import VectorStoreIntegrationTests
|
||||
from langchain_tests.integration_tests.base_store import (
|
||||
BaseStoreAsyncTests,
|
||||
BaseStoreSyncTests,
|
||||
)
|
||||
from langchain_tests.integration_tests.cache import (
|
||||
AsyncCacheTestSuite,
|
||||
SyncCacheTestSuite,
|
||||
)
|
||||
from langchain_tests.integration_tests.chat_models import ChatModelIntegrationTests
|
||||
from langchain_tests.integration_tests.embeddings import EmbeddingsIntegrationTests
|
||||
from langchain_tests.integration_tests.retrievers import RetrieversIntegrationTests
|
||||
from langchain_tests.integration_tests.tools import ToolsIntegrationTests
|
||||
from langchain_tests.integration_tests.vectorstores import VectorStoreIntegrationTests
|
||||
|
||||
__all__ = [
|
||||
"AsyncCacheTestSuite",
|
||||
|
||||
@@ -15,8 +15,8 @@ modules = [
|
||||
for module in modules:
|
||||
pytest.register_assert_rewrite(f"langchain_tests.unit_tests.{module}")
|
||||
|
||||
from .chat_models import ChatModelUnitTests
|
||||
from .embeddings import EmbeddingsUnitTests
|
||||
from .tools import ToolsUnitTests
|
||||
from langchain_tests.unit_tests.chat_models import ChatModelUnitTests
|
||||
from langchain_tests.unit_tests.embeddings import EmbeddingsUnitTests
|
||||
from langchain_tests.unit_tests.tools import ToolsUnitTests
|
||||
|
||||
__all__ = ["ChatModelUnitTests", "EmbeddingsUnitTests", "ToolsUnitTests"]
|
||||
|
||||
@@ -90,6 +90,9 @@ flake8-annotations.mypy-init-return = true
|
||||
flake8-type-checking.runtime-evaluated-base-classes = ["pydantic.BaseModel","langchain_core.load.serializable.Serializable","langchain_core.runnables.base.RunnableSerializable"]
|
||||
pep8-naming.classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_init", "pydantic.field_validator", "pydantic.v1.root_validator",]
|
||||
|
||||
[tool.ruff.lint.flake8-tidy-imports]
|
||||
ban-relative-imports = "all"
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
ignore-var-parameters = true # ignore missing documentation for *args and **kwargs parameters
|
||||
|
||||
0
libs/standard-tests/tests/__init__.py
Normal file
0
libs/standard-tests/tests/__init__.py
Normal file
@@ -8,8 +8,7 @@ import pytest
|
||||
|
||||
from langchain_tests.integration_tests import ChatModelIntegrationTests
|
||||
from langchain_tests.unit_tests import ChatModelUnitTests
|
||||
|
||||
from .custom_chat_model import ChatParrotLink
|
||||
from tests.unit_tests.custom_chat_model import ChatParrotLink
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from langchain_core.language_models.chat_models import BaseChatModel
|
||||
|
||||
2
libs/standard-tests/uv.lock
generated
2
libs/standard-tests/uv.lock
generated
@@ -321,7 +321,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "langchain-core"
|
||||
version = "1.2.5"
|
||||
version = "1.2.6"
|
||||
source = { editable = "../core" }
|
||||
dependencies = [
|
||||
{ name = "jsonpatch" },
|
||||
|
||||
Reference in New Issue
Block a user