Home / Function/ test_docstring_parsing() — langchain Function Reference

test_docstring_parsing() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 1278–1356

def test_docstring_parsing() -> None:
    expected = {
        "title": "foo",
        "description": "The foo.",
        "type": "object",
        "properties": {
            "bar": {"title": "Bar", "description": "The bar.", "type": "string"},
            "baz": {"title": "Baz", "description": "The baz.", "type": "integer"},
        },
        "required": ["bar", "baz"],
    }

    # Simple case
    def foo(bar: str, baz: int) -> str:
        """The foo.

        Args:
            bar: The bar.
            baz: The baz.
        """
        return bar

    as_tool = tool(foo, parse_docstring=True)
    args_schema = _schema(as_tool.args_schema)
    assert args_schema["description"] == "The foo."
    assert args_schema["properties"] == expected["properties"]

    # Multi-line description
    def foo2(bar: str, baz: int) -> str:
        """The foo.

        Additional description here.

        Args:
            bar: The bar.
            baz: The baz.
        """
        return bar

    as_tool = tool(foo2, parse_docstring=True)
    args_schema2 = _schema(as_tool.args_schema)
    assert args_schema2["description"] == "The foo. Additional description here."
    assert args_schema2["properties"] == expected["properties"]

    # Multi-line with Returns block
    def foo3(bar: str, baz: int) -> str:
        """The foo.

        Additional description here.

        Args:
            bar: The bar.
            baz: The baz.

        Returns:
            description of returned value.
        """
        return bar

    as_tool = tool(foo3, parse_docstring=True)
    args_schema3 = _schema(as_tool.args_schema)
    args_schema3["title"] = "foo2"
    assert args_schema2 == args_schema3

    # Single argument
    def foo4(bar: str) -> str:
        """The foo.

        Args:
            bar: The bar.
        """
        return bar

    as_tool = tool(foo4, parse_docstring=True)
    args_schema4 = _schema(as_tool.args_schema)
    assert args_schema4["description"] == "The foo."
    assert args_schema4["properties"] == {
        "bar": {"description": "The bar.", "title": "Bar", "type": "string"}
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_docstring_parsing() do?
test_docstring_parsing() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is test_docstring_parsing() defined?
test_docstring_parsing() is defined in libs/core/tests/unit_tests/test_tools.py at line 1278.
What does test_docstring_parsing() call?
test_docstring_parsing() 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