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

Function deep_reload_hook

IPython/lib/deepreload.py:250–279  ·  view source on GitHub ↗

Replacement for reload().

(m)

Source from the content-addressed store, hash-verified

248modules_reloading = {}
249
250def deep_reload_hook(m):
251 """Replacement for reload()."""
252 # Hardcode this one as it would raise a NotImplementedError from the
253 # bowels of Python and screw up the import machinery after.
254 # unlike other imports the `exclude` list already in place is not enough.
255
256 if m is types:
257 return m
258 if not isinstance(m, ModuleType):
259 raise TypeError("reload() argument must be module")
260
261 name = m.__name__
262
263 if name not in sys.modules:
264 raise ImportError("reload(): module %.200s not in sys.modules" % name)
265
266 global modules_reloading
267 try:
268 return modules_reloading[name]
269 except:
270 modules_reloading[name] = m
271
272 try:
273 newm = importlib.reload(m)
274 except:
275 sys.modules[name] = m
276 raise
277 finally:
278 modules_reloading.clear()
279 return newm
280
281# Save the original hooks
282original_reload = importlib.reload

Callers 1

reloadFunction · 0.85

Calls 1

reloadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…