Home / Function/ _dict_from_ast() — langchain Function Reference

_dict_from_ast() — langchain Function Reference

Architecture documentation for the _dict_from_ast() function in test_imports.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ed754162_a014_59bf_8b3f_a17462a35481["_dict_from_ast()"]
  1a4ae21b_d553_aa88_bac6_fd6971a4e02d["test_imports.py"]
  ed754162_a014_59bf_8b3f_a17462a35481 -->|defined in| 1a4ae21b_d553_aa88_bac6_fd6971a4e02d
  97d4d94c_65f3_c42b_7930_3764d443c63a["extract_deprecated_lookup()"]
  97d4d94c_65f3_c42b_7930_3764d443c63a -->|calls| ed754162_a014_59bf_8b3f_a17462a35481
  fe343a33_7414_9ca3_120c_9230b711167f["_literal_eval_str()"]
  ed754162_a014_59bf_8b3f_a17462a35481 -->|calls| fe343a33_7414_9ca3_120c_9230b711167f
  style ed754162_a014_59bf_8b3f_a17462a35481 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/tests/unit_tests/test_imports.py lines 136–150

def _dict_from_ast(node: ast.Dict) -> dict[str, str]:
    """Convert an AST dict node to a Python dictionary, assuming str to str format.

    Args:
        node: The AST node representing a dictionary.

    Returns:
        The corresponding Python dictionary.
    """
    result: dict[str, str] = {}
    for key, value in zip(node.keys, node.values, strict=False):
        py_key = _literal_eval_str(key)  # type: ignore[arg-type]
        py_value = _literal_eval_str(value)
        result[py_key] = py_value
    return result

Domain

Subdomains

Frequently Asked Questions

What does _dict_from_ast() do?
_dict_from_ast() is a function in the langchain codebase, defined in libs/langchain/tests/unit_tests/test_imports.py.
Where is _dict_from_ast() defined?
_dict_from_ast() is defined in libs/langchain/tests/unit_tests/test_imports.py at line 136.
What does _dict_from_ast() call?
_dict_from_ast() calls 1 function(s): _literal_eval_str.
What calls _dict_from_ast()?
_dict_from_ast() is called by 1 function(s): extract_deprecated_lookup.

Analyze Your Own Codebase

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

Try Supermodel Free