Home / Function/ test_tool_annotations_preserved() — langchain Function Reference

test_tool_annotations_preserved() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  805cd537_ba29_bcf1_099f_4ef88079f459["test_tool_annotations_preserved()"]
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  805cd537_ba29_bcf1_099f_4ef88079f459 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  style 805cd537_ba29_bcf1_099f_4ef88079f459 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 2227–2244

def test_tool_annotations_preserved() -> None:
    """Test that annotations are preserved when creating a tool."""

    @tool
    def my_tool(val: int, other_val: Annotated[dict, "my annotation"]) -> str:
        """Tool docstring."""
        return "foo"

    schema = my_tool.get_input_schema()

    func = my_tool.func  # type: ignore[attr-defined]

    expected_type_hints = {
        name: hint
        for name, hint in func.__annotations__.items()
        if name in inspect.signature(func).parameters
    }
    assert schema.__annotations__ == expected_type_hints

Domain

Subdomains

Frequently Asked Questions

What does test_tool_annotations_preserved() do?
test_tool_annotations_preserved() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_tool_annotations_preserved() defined?
test_tool_annotations_preserved() is defined in libs/core/tests/unit_tests/test_tools.py at line 2227.

Analyze Your Own Codebase

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

Try Supermodel Free