Home / Function/ deprecated() — langchain Function Reference

deprecated() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/_api/deprecation.py lines 89–426

def deprecated(
    since: str,
    *,
    message: str = "",
    name: str = "",
    alternative: str = "",
    alternative_import: str = "",
    pending: bool = False,
    obj_type: str = "",
    addendum: str = "",
    removal: str = "",
    package: str = "",
) -> Callable[[T], T]:
    """Decorator to mark a function, a class, or a property as deprecated.

    When deprecating a classmethod, a staticmethod, or a property, the `@deprecated`
    decorator should go *under* `@classmethod` and `@staticmethod` (i.e., `deprecated`
    should directly decorate the underlying callable), but *over* `@property`.

    When deprecating a class `C` intended to be used as a base class in a multiple
    inheritance hierarchy, `C` *must* define an `__init__` method (if `C` instead
    inherited its `__init__` from its own base class, then `@deprecated` would mess up
    `__init__` inheritance when installing its own (deprecation-emitting) `C.__init__`).

    Parameters are the same as for `warn_deprecated`, except that *obj_type* defaults to
    'class' if decorating a class, 'attribute' if decorating a property, and 'function'
    otherwise.

    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.

    Returns:
        A decorator to mark a function or class as deprecated.

    Example:
        ```python
        @deprecated("1.4.0")
        def the_function_to_deprecate():
            pass
        ```
    """
    _validate_deprecation_params(
        removal, alternative, alternative_import, pending=pending
    )

    def deprecate(
        obj: T,
        *,
        _obj_type: str = obj_type,
        _name: str = name,
        _message: str = message,
        _alternative: str = alternative,
        _alternative_import: str = alternative_import,
        _pending: bool = pending,
        _addendum: str = addendum,

Subdomains

Frequently Asked Questions

What does deprecated() do?
deprecated() is a function in the langchain codebase, defined in libs/core/langchain_core/_api/deprecation.py.
Where is deprecated() defined?
deprecated() is defined in libs/core/langchain_core/_api/deprecation.py at line 89.
What does deprecated() call?
deprecated() calls 3 function(s): _build_deprecation_message, _validate_deprecation_params, warn_deprecated.

Analyze Your Own Codebase

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

Try Supermodel Free