MCPcopy
hub / github.com/python/mypy / silent_import_module

Function silent_import_module

mypy/stubtest.py:218–227  ·  view source on GitHub ↗
(module_name: str)

Source from the content-addressed store, hash-verified

216
217
218def silent_import_module(module_name: str) -> types.ModuleType:
219 with open(os.devnull, "w") as devnull:
220 with warnings.catch_warnings(), redirect_stdout(devnull), redirect_stderr(devnull):
221 warnings.simplefilter("ignore")
222 runtime = importlib.import_module(module_name)
223 # Also run the equivalent of `from module import *`
224 # This could have the additional effect of loading not-yet-loaded submodules
225 # mentioned in __all__
226 __import__(module_name, fromlist=["*"])
227 return runtime
228
229
230def test_module(module_name: str) -> Iterator[Error]:

Callers 3

test_moduleFunction · 0.85
build_stubsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…