Home / Function/ warn_deprecated() — langchain Function Reference

warn_deprecated() — langchain Function Reference

Architecture documentation for the warn_deprecated() function in deprecation.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  67d59e77_60ec_85e8_5f1a_a0382f746cae["warn_deprecated()"]
  94320bb6_6e56_d7f5_79eb_9674de780d72["deprecation.py"]
  67d59e77_60ec_85e8_5f1a_a0382f746cae -->|defined in| 94320bb6_6e56_d7f5_79eb_9674de780d72
  40d7e3e2_e923_83d0_042d_1c39ac220fba["deprecated()"]
  40d7e3e2_e923_83d0_042d_1c39ac220fba -->|calls| 67d59e77_60ec_85e8_5f1a_a0382f746cae
  a732c96b_727a_980f_ccdf_4e665a593325["rename_parameter()"]
  a732c96b_727a_980f_ccdf_4e665a593325 -->|calls| 67d59e77_60ec_85e8_5f1a_a0382f746cae
  style 67d59e77_60ec_85e8_5f1a_a0382f746cae fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/_api/deprecation.py lines 438–535

def warn_deprecated(
    since: str,
    *,
    message: str = "",
    name: str = "",
    alternative: str = "",
    alternative_import: str = "",
    pending: bool = False,
    obj_type: str = "",
    addendum: str = "",
    removal: str = "",
    package: str = "",
) -> None:
    """Display a standardized deprecation.

    Args:
        since: The release at which this API became deprecated.
        message: Override the default deprecation message.

            The `%(since)s`, `%(name)s`, `%(alternative)s`, `%(obj_type)s`,
            `%(addendum)s`, and `%(removal)s` format specifiers will be replaced by the
            values of the respective arguments passed to this function.
        name: The name of the deprecated object.
        alternative: An alternative API that the user may use in place of the
            deprecated API.

            The deprecation warning will tell the user about this alternative if
            provided.
        alternative_import: An alternative import that the user may use instead.
        pending: If `True`, uses a `PendingDeprecationWarning` instead of a
            `DeprecationWarning`.

            Cannot be used together with removal.
        obj_type: The object type being deprecated.
        addendum: Additional text appended directly to the final message.
        removal: The expected removal version.

            With the default (an empty string), a removal version is automatically
            computed from since. Set to other Falsy values to not schedule a removal
            date.

            Cannot be used together with pending.
        package: The package of the deprecated object.
    """
    if not pending:
        if not removal:
            removal = f"in {removal}" if removal else "within ?? minor releases"
            msg = (
                f"Need to determine which default deprecation schedule to use. "
                f"{removal}"
            )
            raise NotImplementedError(msg)
        removal = f"in {removal}"

    if not message:
        message = ""
        package_ = (
            package or name.split(".", maxsplit=1)[0].replace("_", "-")
            if "." in name
            else "LangChain"
        )

        if obj_type:
            message += f"The {obj_type} `{name}`"
        else:
            message += f"`{name}`"

        if pending:
            message += " will be deprecated in a future version"
        else:
            message += f" was deprecated in {package_} {since}"

            if removal:
                message += f" and will be removed {removal}"

        if alternative_import:
            alt_package = alternative_import.split(".", maxsplit=1)[0].replace("_", "-")
            if alt_package == package_:
                message += f". Use {alternative_import} instead."
            else:
                alt_module, alt_name = alternative_import.rsplit(".", 1)

Subdomains

Frequently Asked Questions

What does warn_deprecated() do?
warn_deprecated() is a function in the langchain codebase, defined in libs/core/langchain_core/_api/deprecation.py.
Where is warn_deprecated() defined?
warn_deprecated() is defined in libs/core/langchain_core/_api/deprecation.py at line 438.
What calls warn_deprecated()?
warn_deprecated() is called by 2 function(s): deprecated, rename_parameter.

Analyze Your Own Codebase

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

Try Supermodel Free