Skip to content

Commit 2edba36

Browse files
committed
Allow skipping of unknown modules
1 parent 72febb7 commit 2edba36

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/not_impl_gen.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ def gen_methods(header, footer, output):
6060
output.write("}\n\n")
6161
output.write(footer.read())
6262

63+
def get_module_methods(name):
64+
try:
65+
return set(dir(__import__(name))) if name not in ("this", "antigravity") else None
66+
except ModuleNotFoundError:
67+
return None
68+
6369

6470
def gen_modules(header, footer, output):
6571
output.write(header.read())
@@ -70,9 +76,7 @@ def gen_modules(header, footer, output):
7076
mod.name,
7177
# check name b/c modules listed have side effects on import,
7278
# e.g. printing something or opening a webpage
73-
set(dir(__import__(mod.name)))
74-
if mod.name not in ("this", "antigravity")
75-
else None,
79+
get_module_methods(mod.name)
7680
),
7781
pkgutil.iter_modules(),
7882
)

0 commit comments

Comments
 (0)