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

Function deep_import_hook

IPython/lib/deepreload.py:226–246  ·  view source on GitHub ↗

Replacement for __import__()

(name, globals=None, locals=None, fromlist=None, level=-1)

Source from the content-addressed store, hash-verified

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__()"""
228 parent, buf = get_parent(globals, level)
229
230 head, name, buf = load_next(parent, None if level < 0 else parent, name, buf)
231
232 tail = head
233 while name:
234 tail, name, buf = load_next(tail, tail, name, buf)
235
236 # If tail is None, both get_parent and load_next found
237 # an empty module name: someone called __import__("") or
238 # doctored faulty bytecode
239 if tail is None:
240 raise ValueError('Empty module name')
241
242 if not fromlist:
243 return head
244
245 ensure_fromlist(tail, fromlist, buf, 0)
246 return tail
247
248modules_reloading = {}
249

Callers

nothing calls this directly

Calls 3

get_parentFunction · 0.85
load_nextFunction · 0.85
ensure_fromlistFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…