-
Notifications
You must be signed in to change notification settings - Fork 18.7k
refactor(core): improve beta decorator #32505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
CodSpeed WallTime Performance ReportMerging #32505 will not alter performanceComparing
|
def beta_property(self, value: str) -> None: | ||
return | ||
|
||
@beta() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tips: when using setter and/or deleter, need to put the beta
decorator on the last method.
CodSpeed Instrumentation Performance ReportMerging #32505 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great refactor! The code is much cleaner and easier to understand. The tests are also much more comprehensive. Well done!
8400260
to
404070a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the beta decorator's property handling by replacing a custom _BetaProperty
subclass with a standard property
object created using wrapper functions. This change improves docstring accessibility, allowing ClassWithBetaMethods.beta_property.__doc__
to work correctly.
Key Changes:
- Simplified property decoration by removing the custom
_BetaProperty
subclass - Created wrapper functions (
_fget
,_fset
,_fdel
) that emit warnings and delegate to the original property methods - Updated tests to verify multiple property operations (get, set, delete) all trigger beta warnings
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
libs/core/langchain_core/_api/beta_decorator.py |
Replaced custom _BetaProperty subclass with standard property using wrapper functions |
libs/core/tests/unit_tests/_api/test_beta_decorator.py |
Added property setter/deleter to test class and updated tests to verify all property operations emit warnings |
@beta() # type: ignore[misc] | ||
@beta_property.deleter | ||
def beta_property(self) -> None: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Explicit return
statements are unnecessary in functions that return None
. This can be removed for cleaner code.
return | |
pass |
Copilot uses AI. Check for mistakes.
This is better than using a subclass as returning a
property
works withClassWithBetaMethods.beta_property.__doc__