Skip to content

Commit

Permalink
Extend the shim pickleshare library and fix the store magic to use .g…
Browse files Browse the repository at this point in the history
…et (#14321)

This should make it more obvious what is happening.

Closes #14235
  • Loading branch information
Carreau committed Feb 8, 2024
2 parents 27b7f55 + 7ba57fb commit 3d02f18
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions IPython/core/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,29 @@ class PickleShareDB: # type: ignore [no-redef]
def __init__(self, path):
pass

def get(self, key, default):
def get(self, key, default=None):
warn(
f"using {key} requires you to install the `pickleshare` library.",
f"This is now an optional IPython functionality, using {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)
return default

def __getitem__(self, key):
warn(
f"This is now an optional IPython functionality, using {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)
return None

def __setitem__(self, key, value):
warn(
f"using {key} requires you to install the `pickleshare` library.",
f"This is now an optional IPython functionality, setting {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)

def __delitem__(self, key):
warn(
f"This is now an optional IPython functionality, deleting {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)

Expand Down
2 changes: 1 addition & 1 deletion IPython/extensions/storemagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def store(self, parameter_s=''):
if args:
for arg in args:
try:
obj = db['autorestore/' + arg]
obj = db["autorestore/" + arg]
except KeyError:
try:
restore_aliases(ip, alias=arg)
Expand Down

0 comments on commit 3d02f18

Please sign in to comment.