-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
task: added warning when none is called in intervention handler #4149
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
@@ -14,6 +14,27 @@ | |||
class DropMessage: ... | |||
|
|||
|
|||
def warn_if_none(result: Any, handler_name: str) -> Any: |
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.
Please name this with a leading underscore to indicate private
@@ -14,6 +14,27 @@ | |||
class DropMessage: ... | |||
|
|||
|
|||
def warn_if_none(result: Any, handler_name: str) -> Any: |
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.
IMO there's no reason to return the value, and by doing so you're stripping the type away from it since you're using Any
. I'd say best off to just check and warn and return as normal like before
Why are these changes needed?
The user may be returning none by mistake, explicitly informing them about it can be helpful
I have used the Python in-built library warnings to fix this issue, it checks if a handler call is None, if it is. It returns a warning otherwise returns the original result
Related issue number
Closes #3621
Note
I ran all tests and ran into some issues with
autogen-core\tests\execution\test_user_defined_functions.py
. I am unsure if it was caused by my changes, but I believe that should not be the case.Checks