From ec51c50f300de0eb94548582888796102ff2872a Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Fri, 24 Nov 2023 10:00:27 +0100 Subject: [PATCH] Silence PickleShare warnings when completing root modules. A better way woudl be to try to use the shelves module ? --- IPython/core/completerlib.py | 5 ++++- IPython/core/interactiveshell.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index 5e59c6abcdf..29ddab18560 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 0a528c51f20..67727404f9d 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -42,6 +42,8 @@ except ModuleNotFoundError: class PickleShareDB: # type: ignore [no-redef] + _mock = True + def __init__(self, path): pass