From 30e5a5d3346e5caf5a03a2d253084bfbd569ad42 2021-11-26 16:46:12 From: Nikita Kniazev Date: 2021-11-26 16:46:12 Subject: [PATCH] deepreload: Use `sys.builtin_module_names` to exclude builtins --- diff --git a/IPython/lib/deepreload.py b/IPython/lib/deepreload.py index fa8009b..aaedab2 100644 --- a/IPython/lib/deepreload.py +++ b/IPython/lib/deepreload.py @@ -282,11 +282,22 @@ def deep_reload_hook(m): original_reload = importlib.reload # Replacement for reload() -def reload(module, exclude=('sys', 'os.path', 'builtins', '__main__', - 'numpy', 'numpy._globals')): +def reload( + module, + exclude=( + *sys.builtin_module_names, + "sys", + "os.path", + "builtins", + "__main__", + "numpy", + "numpy._globals", + ), +): """Recursively reload all modules used in the given module. Optionally takes a list of modules to exclude from reloading. The default exclude - list contains sys, __main__, and __builtin__, to prevent, e.g., resetting + list contains modules listed in sys.builtin_module_names with additional + sys, os.path, builtins and __main__, to prevent, e.g., resetting display, exception, and io hooks. """ global found_now