Home / Function/ test__get_all_basemodel_annotations_v2() — langchain Function Reference

test__get_all_basemodel_annotations_v2() — langchain Function Reference

Architecture documentation for the test__get_all_basemodel_annotations_v2() function in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  02a6bd4a_1b29_a0e5_4be1_ae6a51f13fc7["test__get_all_basemodel_annotations_v2()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  02a6bd4a_1b29_a0e5_4be1_ae6a51f13fc7 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  b621c544_d6db_7e8d_7240_9ce08870d71a["foo()"]
  02a6bd4a_1b29_a0e5_4be1_ae6a51f13fc7 -->|calls| b621c544_d6db_7e8d_7240_9ce08870d71a
  style 02a6bd4a_1b29_a0e5_4be1_ae6a51f13fc7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 2143–2215

def test__get_all_basemodel_annotations_v2(*, use_v1_namespace: bool) -> None:
    A = TypeVar("A")

    if use_v1_namespace:
        if sys.version_info >= (3, 14):
            pytest.skip("pydantic.v1 namespace not supported with Python 3.14+")

        class ModelA(BaseModelV1, Generic[A], extra="allow"):
            a: A

        class EmptyModel(BaseModelV1, Generic[A], extra="allow"):
            pass
    else:

        class ModelA(BaseModel, Generic[A]):  # type: ignore[no-redef]
            a: A
            model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")

        class EmptyModel(BaseModel, Generic[A]):  # type: ignore[no-redef]
            model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")

    class ModelB(ModelA[str]):
        b: Annotated[ModelA[dict[str, Any]], "foo"]

    class Mixin:
        def foo(self) -> str:
            return "foo"

    class ModelC(Mixin, ModelB):
        c: dict

    expected = {"a": str, "b": Annotated[ModelA[dict[str, Any]], "foo"], "c": dict}
    actual = get_all_basemodel_annotations(ModelC)
    assert actual == expected

    expected = {"a": str, "b": Annotated[ModelA[dict[str, Any]], "foo"]}
    actual = get_all_basemodel_annotations(ModelB)
    assert actual == expected

    expected = {"a": Any}
    actual = get_all_basemodel_annotations(ModelA)
    assert actual == expected

    expected = {"a": int}
    actual = get_all_basemodel_annotations(ModelA[int])
    assert actual == expected

    D = TypeVar("D", bound=str | int)

    class ModelD(ModelC, Generic[D]):
        d: D | None

    expected = {
        "a": str,
        "b": Annotated[ModelA[dict[str, Any]], "foo"],
        "c": dict,
        "d": str | int | None,
    }
    actual = get_all_basemodel_annotations(ModelD)
    assert actual == expected

    expected = {
        "a": str,
        "b": Annotated[ModelA[dict[str, Any]], "foo"],
        "c": dict,
        "d": int | None,
    }
    actual = get_all_basemodel_annotations(ModelD[int])
    assert actual == expected

    expected = {}
    actual = get_all_basemodel_annotations(EmptyModel)
    assert actual == expected

Domain

Subdomains

Calls

Frequently Asked Questions

What does test__get_all_basemodel_annotations_v2() do?
test__get_all_basemodel_annotations_v2() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test__get_all_basemodel_annotations_v2() defined?
test__get_all_basemodel_annotations_v2() is defined in libs/core/tests/unit_tests/test_tools.py at line 2143.
What does test__get_all_basemodel_annotations_v2() call?
test__get_all_basemodel_annotations_v2() calls 1 function(s): foo.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free