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

Method unload_extension

IPython/core/extensions.py:84–104  ·  view source on GitHub ↗

Unload an IPython extension by its module name. This function looks up the extension's name in ``sys.modules`` and simply calls ``mod.unload_ipython_extension(self)``. Returns the string "no unload function" if the extension doesn't define a function to unload itsel

(self, module_str: str)

Source from the content-addressed store, hash-verified

82 return "no load function"
83
84 def unload_extension(self, module_str: str):
85 """Unload an IPython extension by its module name.
86
87 This function looks up the extension's name in ``sys.modules`` and
88 simply calls ``mod.unload_ipython_extension(self)``.
89
90 Returns the string "no unload function" if the extension doesn't define
91 a function to unload itself, "not loaded" if the extension isn't loaded,
92 otherwise None.
93 """
94 if BUILTINS_EXTS.get(module_str, False) is True:
95 module_str = "IPython.extensions." + module_str
96 if module_str not in self.loaded:
97 return "not loaded"
98
99 if module_str in sys.modules:
100 mod = sys.modules[module_str]
101 if self._call_unload_ipython_extension(mod):
102 self.loaded.discard(module_str)
103 else:
104 return "no unload function"
105
106 def reload_extension(self, module_str: str):
107 """Reload an IPython extension by calling reload.

Callers 3

reload_extensionMethod · 0.95
unload_extMethod · 0.80
test_extension_loadingFunction · 0.80

Calls 2

getMethod · 0.80

Tested by 1

test_extension_loadingFunction · 0.64