Home / Function/ test_pre_init_decorator() — langchain Function Reference

test_pre_init_decorator() — langchain Function Reference

Architecture documentation for the test_pre_init_decorator() function in test_pydantic.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  8c6b168d_a098_c996_60c0_f6a200bed304["test_pre_init_decorator()"]
  f94b56e0_336c_6748_3628_73edd4212b01["test_pydantic.py"]
  8c6b168d_a098_c996_60c0_f6a200bed304 -->|defined in| f94b56e0_336c_6748_3628_73edd4212b01
  edab1b9c_414d_0bfb_72fb_78e0cdb41fef["validator()"]
  8c6b168d_a098_c996_60c0_f6a200bed304 -->|calls| edab1b9c_414d_0bfb_72fb_78e0cdb41fef
  style 8c6b168d_a098_c996_60c0_f6a200bed304 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/utils/test_pydantic.py lines 21–35

def test_pre_init_decorator() -> None:
    class Foo(BaseModel):
        x: int = 5
        y: int

        @pre_init
        def validator(cls, v: dict[str, Any]) -> dict[str, Any]:
            v["y"] = v["x"] + 1
            return v

    # Type ignore initialization b/c y is marked as required
    foo = Foo()  # type: ignore[call-arg]
    assert foo.y == 6
    foo = Foo(x=10)  # type: ignore[call-arg]
    assert foo.y == 11

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_pre_init_decorator() do?
test_pre_init_decorator() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_pydantic.py.
Where is test_pre_init_decorator() defined?
test_pre_init_decorator() is defined in libs/core/tests/unit_tests/utils/test_pydantic.py at line 21.
What does test_pre_init_decorator() call?
test_pre_init_decorator() calls 1 function(s): validator.

Analyze Your Own Codebase

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

Try Supermodel Free