From f55186b38f9501830558967e6526ead35440e449 Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Mon, 11 Aug 2025 18:43:53 +0200 Subject: [PATCH] fix(core): fix beta decorator for properties (#32497) --- libs/core/langchain_core/_api/beta_decorator.py | 2 +- libs/core/tests/unit_tests/_api/test_beta_decorator.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/core/langchain_core/_api/beta_decorator.py b/libs/core/langchain_core/_api/beta_decorator.py index 4849a195f1d..f4a9260c1bc 100644 --- a/libs/core/langchain_core/_api/beta_decorator.py +++ b/libs/core/langchain_core/_api/beta_decorator.py @@ -147,7 +147,6 @@ def beta( return cast("T", obj) elif isinstance(obj, property): - # note(erick): this block doesn't seem to be used? if not _obj_type: _obj_type = "attribute" wrapped = None @@ -168,6 +167,7 @@ def beta( self.__orig_fget = fget self.__orig_fset = fset self.__orig_fdel = fdel + self.__doc__ = doc def __get__( self, instance: Any, owner: Union[type, None] = None diff --git a/libs/core/tests/unit_tests/_api/test_beta_decorator.py b/libs/core/tests/unit_tests/_api/test_beta_decorator.py index 6cbbfe05988..fb396505342 100644 --- a/libs/core/tests/unit_tests/_api/test_beta_decorator.py +++ b/libs/core/tests/unit_tests/_api/test_beta_decorator.py @@ -91,8 +91,8 @@ class ClassWithBetaMethods: """Original doc.""" return "This is a beta staticmethod." + @beta() # type: ignore[prop-decorator] @property - @beta() def beta_property(self) -> str: """Original doc.""" return "This is a beta property." @@ -226,10 +226,10 @@ def test_beta_property() -> None: warning = warning_list[0].message assert str(warning) == ( - "The method `ClassWithBetaMethods.beta_property` is in beta. " + "The attribute `ClassWithBetaMethods.beta_property` is in beta. " "It is actively being worked on, so the API may change." ) - doc = ClassWithBetaMethods.beta_property.__doc__ + doc = ClassWithBetaMethods.__dict__["beta_property"].__doc__ assert isinstance(doc, str) assert doc.startswith(".. beta::")