From ec51c50f300de0eb94548582888796102ff2872a 2023-11-24 09:22:16 From: Matthias Bussonnier Date: 2023-11-24 09:22:16 Subject: [PATCH] Silence PickleShare warnings when completing root modules. A better way woudl be to try to use the shelves module ? --- diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index 5e59c6a..29ddab1 100644 --- a/IPython/core/completerlib.py +++ b/IPython/core/completerlib.py @@ -117,7 +117,10 @@ def get_root_modules(): # Don't try to scan for modules every time. return list(sys.builtin_module_names) - rootmodules_cache = ip.db.get('rootmodules_cache', {}) + if getattr(ip.db, "_mock", False): + rootmodules_cache = {} + else: + rootmodules_cache = ip.db.get("rootmodules_cache", {}) rootmodules = list(sys.builtin_module_names) start_time = time() store = False diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 0a528c5..6772740 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -42,6 +42,8 @@ try: except ModuleNotFoundError: class PickleShareDB: # type: ignore [no-redef] + _mock = True + def __init__(self, path): pass