mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-13 22:59:05 +00:00
fix(core): fix beta decorator for properties (#32497)
This commit is contained in:
parent
374f414c91
commit
f55186b38f
@ -147,7 +147,6 @@ def beta(
|
|||||||
return cast("T", obj)
|
return cast("T", obj)
|
||||||
|
|
||||||
elif isinstance(obj, property):
|
elif isinstance(obj, property):
|
||||||
# note(erick): this block doesn't seem to be used?
|
|
||||||
if not _obj_type:
|
if not _obj_type:
|
||||||
_obj_type = "attribute"
|
_obj_type = "attribute"
|
||||||
wrapped = None
|
wrapped = None
|
||||||
@ -168,6 +167,7 @@ def beta(
|
|||||||
self.__orig_fget = fget
|
self.__orig_fget = fget
|
||||||
self.__orig_fset = fset
|
self.__orig_fset = fset
|
||||||
self.__orig_fdel = fdel
|
self.__orig_fdel = fdel
|
||||||
|
self.__doc__ = doc
|
||||||
|
|
||||||
def __get__(
|
def __get__(
|
||||||
self, instance: Any, owner: Union[type, None] = None
|
self, instance: Any, owner: Union[type, None] = None
|
||||||
|
@ -91,8 +91,8 @@ class ClassWithBetaMethods:
|
|||||||
"""Original doc."""
|
"""Original doc."""
|
||||||
return "This is a beta staticmethod."
|
return "This is a beta staticmethod."
|
||||||
|
|
||||||
|
@beta() # type: ignore[prop-decorator]
|
||||||
@property
|
@property
|
||||||
@beta()
|
|
||||||
def beta_property(self) -> str:
|
def beta_property(self) -> str:
|
||||||
"""Original doc."""
|
"""Original doc."""
|
||||||
return "This is a beta property."
|
return "This is a beta property."
|
||||||
@ -226,10 +226,10 @@ def test_beta_property() -> None:
|
|||||||
warning = warning_list[0].message
|
warning = warning_list[0].message
|
||||||
|
|
||||||
assert str(warning) == (
|
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."
|
"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 isinstance(doc, str)
|
||||||
assert doc.startswith(".. beta::")
|
assert doc.startswith(".. beta::")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user