Skip to content

Do not wrap types in safer_func #1475

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

Merged
merged 3 commits into from
Jun 24, 2025

Conversation

albertvillanova
Copy link
Member

Prevent unnecessary wrapping of type objects in the safer_func decorator.

Previously, all functions including type objects like int, str, etc. were being wrapped with safety checks. This created overhead for operations that only use types as references (not calls), such as isinstance(5, int).

This PR adds a check to detect if the function is a type object and return it directly without wrapping

Fix #1474.

@albertvillanova albertvillanova marked this pull request as draft June 23, 2025 13:27
@albertvillanova albertvillanova marked this pull request as ready for review June 23, 2025 13:51
Copy link
Collaborator

@aymeric-roucher aymeric-roucher left a comment

Choose a reason for hiding this comment

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

Thank you @albertvillanova !

@albertvillanova albertvillanova merged commit 0e24929 into huggingface:main Jun 24, 2025
4 of 5 checks passed
@albertvillanova albertvillanova deleted the fix-1474 branch June 24, 2025 07:37
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.

[BUG] Local python executor fails to run isinstance function
2 participants