Skip to content

Check authorized imports in LocalPythonInterpreter constructor #265

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 14 commits into from
Jul 10, 2025

Conversation

jank
Copy link
Contributor

@jank jank commented Jan 18, 2025

Checking if authorized_imports exist was marked as TODO in the comment.
This MR implements this functionality and adds tests.
Also adds a test option to the makefile to skip the tests of DocStrings, which require API keys.

@@ -1529,7 +1530,12 @@ def __init__(
**tools,
**BASE_PYTHON_TOOLS.copy(),
}
# TODO: assert self.authorized imports are all installed locally
# assert self.authorized imports are all installed locally
missing_modules = [imp for imp in self.authorized_imports if find_spec(imp) is None]
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an issue here if additional_authorized_imports includes "*". A check should be added to ensure "*" is working properly.

@jank
Copy link
Contributor Author

jank commented Jan 28, 2025

@AngeloKiriakoulis good catch on the wildcard import. I added a test case for the wildcard import and fixed the implementation. Ran make style on changed files.

@jank
Copy link
Contributor Author

jank commented Jul 10, 2025

any chance of getting this merged? Alternatively, I would just close and delete this MR.

Copy link
Member

@albertvillanova albertvillanova left a comment

Choose a reason for hiding this comment

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

Thanks!

I fixed it to support partial star-pattern introduced by:

Also, I extracted the code to a dedicated method, refactored the test, and fixed the conflicts with the main branch.

@albertvillanova albertvillanova merged commit 0e55d7a into huggingface:main Jul 10, 2025
3 checks passed
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.

4 participants