From 9dfd3122dc1fc1461a47cc76e6254a94e4923f04 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 5 Sep 2026 23:11:25 +0000 Subject: [PATCH] test(lazy_imports): capture globals() before the star-import audit comprehension The subprocess-level star-import audit called dir() inside a list comprehension, which returns the comprehension's own scope on CPython 3.10/3.11/3.13/3.14 (and only accidentally exposed the module globals on 3.12), so every name in litellm.__all__ registered as missing and misc / Run tests failed on those matrix cells. Snapshot globals() into a local before the comprehension so the audit always sees the module-level bindings that from litellm import * just created. Co-authored-by: Krrish Dholakia --- tests/test_litellm/test_lazy_imports.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_litellm/test_lazy_imports.py b/tests/test_litellm/test_lazy_imports.py index 09d5e23e2e6..34d5f1d1e41 100644 --- a/tests/test_litellm/test_lazy_imports.py +++ b/tests/test_litellm/test_lazy_imports.py @@ -408,7 +408,8 @@ def test_star_import_exports_public_api(): code = ( "from litellm import *\n" "import litellm\n" - "missing = [n for n in litellm.__all__ if n not in dir()]\n" + "bound = globals()\n" + "missing = [n for n in litellm.__all__ if n not in bound]\n" "assert not missing, missing[:20]\n" "assert callable(completion) and callable(Router)\n" )