Home / Function/ rename_parameter() — langchain Function Reference

rename_parameter() — langchain Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

libs/core/langchain_core/_api/deprecation.py lines 555–603

def rename_parameter(
    *,
    since: str,
    removal: str,
    old: str,
    new: str,
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]:
    """Decorator indicating that parameter *old* of *func* is renamed to *new*.

    The actual implementation of *func* should use *new*, not *old*. If *old* is passed
    to *func*, a `DeprecationWarning` is emitted, and its value is used, even if *new*
    is also passed by keyword.

    Args:
        since: The version in which the parameter was renamed.
        removal: The version in which the old parameter will be removed.
        old: The old parameter name.
        new: The new parameter name.

    Returns:
        A decorator indicating that a parameter was renamed.

    Example:
        ```python
        @_api.rename_parameter("3.1", "bad_name", "good_name")
        def func(good_name): ...
        ```
    """

    def decorator(f: Callable[_P, _R]) -> Callable[_P, _R]:
        @functools.wraps(f)
        def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
            if new in kwargs and old in kwargs:
                msg = f"{f.__name__}() got multiple values for argument {new!r}"
                raise TypeError(msg)
            if old in kwargs:
                warn_deprecated(
                    since,
                    removal=removal,
                    message=f"The parameter `{old}` of `{f.__name__}` was "
                    f"deprecated in {since} and will be removed "
                    f"in {removal} Use `{new}` instead.",
                )
                kwargs[new] = kwargs.pop(old)
            return f(*args, **kwargs)

        return wrapper

    return decorator

Subdomains

Frequently Asked Questions

What does rename_parameter() do?
rename_parameter() is a function in the langchain codebase, defined in libs/core/langchain_core/_api/deprecation.py.
Where is rename_parameter() defined?
rename_parameter() is defined in libs/core/langchain_core/_api/deprecation.py at line 555.
What does rename_parameter() call?
rename_parameter() calls 1 function(s): warn_deprecated.

Analyze Your Own Codebase

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

Try Supermodel Free