MCPcopy Index your code
hub / github.com/ipython/ipython / ensure_fromlist

Function ensure_fromlist

IPython/lib/deepreload.py:205–224  ·  view source on GitHub ↗

Handle 'from module import a, b, c' imports.

(mod, fromlist, buf, recursive)

Source from the content-addressed store, hash-verified

203 return
204
205def ensure_fromlist(mod, fromlist, buf, recursive):
206 """Handle 'from module import a, b, c' imports."""
207 if not hasattr(mod, '__path__'):
208 return
209 for item in fromlist:
210 if not hasattr(item, 'rindex'):
211 raise TypeError("Item in ``from list'' not a string")
212 if item == '*':
213 if recursive:
214 continue # avoid endless recursion
215 try:
216 all = mod.__all__
217 except AttributeError:
218 pass
219 else:
220 ret = ensure_fromlist(mod, all, buf, 1)
221 if not ret:
222 return 0
223 elif not hasattr(mod, item):
224 import_submodule(mod, item, buf + '.' + item)
225
226def deep_import_hook(name, globals=None, locals=None, fromlist=None, level=-1):
227 """Replacement for __import__()"""

Callers 1

deep_import_hookFunction · 0.85

Calls 1

import_submoduleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…