Skip to content
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

Fix evaluate_condition for non-bool result #638

Merged

Conversation

albertvillanova
Copy link
Member

@albertvillanova albertvillanova commented Feb 13, 2025

Fix evaluate_condition for non-bool result, as discussed in:

I think there are 2 bugs in evaluate_condition:

@albertvillanova albertvillanova marked this pull request as ready for review February 14, 2025 08:18
Comment on lines -718 to -720
comparators = [
evaluate_ast(c, state, static_tools, custom_tools, authorized_imports) for c in condition.comparators
]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the evaluate_ast inside the loop, we avoid evaluating it for all condition.comparators.

  • Now, once a current_result is False, we return False

@albertvillanova albertvillanova merged commit 9437133 into huggingface:main Feb 14, 2025
3 checks passed
@kc9zyz
Copy link
Contributor

kc9zyz commented Feb 17, 2025

Thanks for cleaning this up @albertvillanova! I hadn't considered chained conditions in my PR, and I think your simplifications improve readability!

@albertvillanova
Copy link
Member Author

Thank YOU, @kc9zyz. It was your PR which addressed the issue of non-bool results! Thanks again for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants