Skip to content

Commit 7580e92

Browse files
committed
Exclude modules in collection of used names
1 parent 49ad5e1 commit 7580e92

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/zeropybench/_jax.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,19 @@ def _create_bench_func(self, args: list[str], combined: dict[str, Any]) -> tuple
230230
def _collect_used_names(self) -> set[str]:
231231
"""Collect variable names used in the AST.
232232
233-
Keep only names in locals/globals, exclude builtins, callables,
233+
Keep only names in locals/globals, exclude builtins, callables, modules,
234234
and names that are assigned in the code (local variables).
235235
"""
236+
from types import ModuleType
237+
236238
loaded_names = self._collect_loaded_names()
237239
assigned_names = self._collect_assigned_names()
238240
return {
239241
name
240242
for name in loaded_names - assigned_names
241-
if name in self.globals and not callable(self.globals[name])
243+
if name in self.globals
244+
and not callable(self.globals[name])
245+
and not isinstance(self.globals[name], ModuleType)
242246
}
243247

244248
def _collect_loaded_names(self) -> set[str]:

0 commit comments

Comments
 (0)