libs/core/langchain_core/_api/__init__.py PYTHON 88 lines View on github.com → Search inside
1"""Helper functions for managing the LangChain API.23This module is only relevant for LangChain developers, not for users.45!!! warning67    This module and its submodules are for internal use only. Do not use them in your8    own code. We may change the API at any time with no warning.9"""1011from typing import TYPE_CHECKING1213from langchain_core._import_utils import import_attr1415if TYPE_CHECKING:16    from langchain_core._api.beta_decorator import (17        LangChainBetaWarning,18        beta,19        suppress_langchain_beta_warning,20        surface_langchain_beta_warnings,21    )22    from langchain_core._api.deprecation import (23        LangChainDeprecationWarning,24        deprecated,25        suppress_langchain_deprecation_warning,26        surface_langchain_deprecation_warnings,27        warn_deprecated,28    )29    from langchain_core._api.path import as_import_path, get_relative_path3031__all__ = (32    "LangChainBetaWarning",33    "LangChainDeprecationWarning",34    "as_import_path",35    "beta",36    "deprecated",37    "get_relative_path",38    "suppress_langchain_beta_warning",39    "suppress_langchain_deprecation_warning",40    "surface_langchain_beta_warnings",41    "surface_langchain_deprecation_warnings",42    "warn_deprecated",43)4445_dynamic_imports = {46    "LangChainBetaWarning": "beta_decorator",47    "beta": "beta_decorator",48    "suppress_langchain_beta_warning": "beta_decorator",49    "surface_langchain_beta_warnings": "beta_decorator",50    "as_import_path": "path",51    "get_relative_path": "path",52    "LangChainDeprecationWarning": "deprecation",53    "deprecated": "deprecation",54    "surface_langchain_deprecation_warnings": "deprecation",55    "suppress_langchain_deprecation_warning": "deprecation",56    "warn_deprecated": "deprecation",57}585960def __getattr__(attr_name: str) -> object:61    """Dynamically import and return an attribute from a submodule.6263    This function enables lazy loading of API functions from submodules, reducing64    initial import time and circular dependency issues.6566    Args:67        attr_name: Name of the attribute to import.6869    Returns:70        The imported attribute object.7172    Raises:73        AttributeError: If the attribute is not a valid dynamic import.74    """75    module_name = _dynamic_imports.get(attr_name)76    result = import_attr(attr_name, module_name, __spec__.parent)77    globals()[attr_name] = result78    return result798081def __dir__() -> list[str]:82    """Return a list of available attributes for this module.8384    Returns:85        List of attribute names that can be imported from this module.86    """87    return list(__all__)

Code quality findings 1

Avoid unnecessary list conversions; use generators where possible
unnecessary-list
return list(__all__)

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.