ipykernel-helper 0.0.44__tar.gz → 0.0.46__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipykernel-helper
3
- Version: 0.0.44
3
+ Version: 0.0.46
4
4
  Summary: Helpers for ipykernel and friends
5
5
  Author-email: Jeremy Howard <info@fast.ai>
6
6
  License: Apache-2.0
@@ -0,0 +1,2 @@
1
+ __version__ = "0.0.46"
2
+ from .core import *
@@ -49,6 +49,7 @@ d = { 'settings': { 'branch': 'main',
49
49
  'ipykernel_helper.core._param_idx': ('core.html#_param_idx', 'ipykernel_helper/core.py'),
50
50
  'ipykernel_helper.core._rank': ('core.html#_rank', 'ipykernel_helper/core.py'),
51
51
  'ipykernel_helper.core._safe_repr': ('core.html#_safe_repr', 'ipykernel_helper/core.py'),
52
+ 'ipykernel_helper.core._safe_sig': ('core.html#_safe_sig', 'ipykernel_helper/core.py'),
52
53
  'ipykernel_helper.core._signatures': ('core.html#_signatures', 'ipykernel_helper/core.py'),
53
54
  'ipykernel_helper.core.fix_editable_priority': ( 'core.html#fix_editable_priority',
54
55
  'ipykernel_helper/core.py'),
@@ -50,6 +50,10 @@ def _safe_repr(obj, max_len=200):
50
50
  except Exception as e: return f"<repr error: {str(e)}>"
51
51
 
52
52
  # %% ../nbs/00_core.ipynb #1e600ee2
53
+ def _safe_sig(v):
54
+ try: return str(signature(v))
55
+ except Exception: return '(...)'
56
+
53
57
  @patch
54
58
  def user_items(self:InteractiveShell, max_len=200, xtra_skip=()):
55
59
  "Get user-defined vars & funcs from namespace."
@@ -66,7 +70,7 @@ def user_items(self:InteractiveShell, max_len=200, xtra_skip=()):
66
70
  if not k in ignore and k not in nsh}
67
71
  user_vars = {k:_safe_repr(v, max_len=max_len)
68
72
  for k, v in user_items.items() if not k.startswith('_') and not isinstance(v, rm_types)}
69
- user_fns = {k:str(signature(v)) for k, v in user_items.items()
73
+ user_fns = {k:_safe_sig(v) for k, v in user_items.items()
70
74
  if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
71
75
  return user_vars,user_fns
72
76
 
@@ -387,7 +391,7 @@ def structured_traceback(self:SyntaxTB, etype, evalue, etb, tb_offset=None, cont
387
391
  def _getfile(obj): return str(inspect._orig_getfile(obj))
388
392
 
389
393
  # %% ../nbs/00_core.ipynb #ff4984b9
390
- @patch()
394
+ @patch
391
395
  async def run_cell_magic(self:InteractiveShell, magic_name, line, cell):
392
396
  result = self._orig_run_cell_magic(magic_name, line, cell)
393
397
  if inspect.iscoroutine(result): result = await result
@@ -395,7 +399,7 @@ async def run_cell_magic(self:InteractiveShell, magic_name, line, cell):
395
399
  return result
396
400
 
397
401
  def _await_cell_magic(lines):
398
- if lines and 'get_ipython().run_cell_magic(' in lines[0] and 'await ' not in lines[0]: lines = ['await ' + lines[0]] + lines[1:]
402
+ if lines and lines[0].lstrip().startswith('get_ipython().run_cell_magic('): lines[0] = f'await {lines[0]}'
399
403
  return lines
400
404
 
401
405
  def load_ipython_extension(ip):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipykernel-helper
3
- Version: 0.0.44
3
+ Version: 0.0.46
4
4
  Summary: Helpers for ipykernel and friends
5
5
  Author-email: Jeremy Howard <info@fast.ai>
6
6
  License: Apache-2.0
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.44"
2
- from .core import *