Home / File/ check_imports.py — langchain Source File

check_imports.py — langchain Source File

Architecture documentation for check_imports.py, a python file in the langchain codebase. 5 imports, 0 dependents.

File python CoreAbstractions Serialization 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  d580f62d_0c05_02e8_fddf_74317c55d992["check_imports.py"]
  d1277855_b602_121e_7de9_23a45b72f1fe["random"]
  d580f62d_0c05_02e8_fddf_74317c55d992 --> d1277855_b602_121e_7de9_23a45b72f1fe
  06ab3965_70ce_6e2c_feb9_564d849aa5f4["string"]
  d580f62d_0c05_02e8_fddf_74317c55d992 --> 06ab3965_70ce_6e2c_feb9_564d849aa5f4
  d76a28c2_c3ab_00a8_5208_77807a49449d["sys"]
  d580f62d_0c05_02e8_fddf_74317c55d992 --> d76a28c2_c3ab_00a8_5208_77807a49449d
  bfa79181_b1e6_eba2_0d8e_9ddb8d3b949c["traceback"]
  d580f62d_0c05_02e8_fddf_74317c55d992 --> bfa79181_b1e6_eba2_0d8e_9ddb8d3b949c
  2acfe0b8_5002_f60d_8c72_d2f95e51daeb["importlib.machinery"]
  d580f62d_0c05_02e8_fddf_74317c55d992 --> 2acfe0b8_5002_f60d_8c72_d2f95e51daeb
  style d580f62d_0c05_02e8_fddf_74317c55d992 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Check Imports Script.

Quickly verify that a list of Python files can be loaded by the Python interpreter
without raising any errors. Ran before running more expensive tests. Useful in
Makefiles.

If loading a file fails, the script prints the problematic filename and the detailed
error traceback.
"""

import random
import string
import sys
import traceback
from importlib.machinery import SourceFileLoader

if __name__ == "__main__":
    files = sys.argv[1:]
    has_failure = False
    for file in files:
        try:
            module_name = "".join(
                random.choice(string.ascii_letters)  # noqa: S311
                for _ in range(20)
            )
            SourceFileLoader(module_name, file).load_module()
        except Exception:  # noqa: BLE001
            has_failure = True
            print(file)  # noqa: T201
            traceback.print_exc()
            print()  # noqa: T201

    sys.exit(1 if has_failure else 0)

Subdomains

Functions

Dependencies

  • importlib.machinery
  • random
  • string
  • sys
  • traceback

Frequently Asked Questions

What does check_imports.py do?
check_imports.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in check_imports.py?
check_imports.py defines 1 function(s): files.
What does check_imports.py depend on?
check_imports.py imports 5 module(s): importlib.machinery, random, string, sys, traceback.
Where is check_imports.py in the architecture?
check_imports.py is located at libs/langchain/scripts/check_imports.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/scripts).

Analyze Your Own Codebase

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

Try Supermodel Free