ipykernel-helper 0.0.2__py3-none-any.whl → 0.0.4__py3-none-any.whl
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.
Potentially problematic release.
This version of ipykernel-helper might be problematic. Click here for more details.
- ipykernel_helper/__init__.py +1 -1
- ipykernel_helper/_modidx.py +17 -8
- ipykernel_helper/core.py +43 -26
- {ipykernel_helper-0.0.2.dist-info → ipykernel_helper-0.0.4.dist-info}/METADATA +1 -1
- ipykernel_helper-0.0.4.dist-info/RECORD +9 -0
- ipykernel_helper-0.0.2.dist-info/RECORD +0 -9
- {ipykernel_helper-0.0.2.dist-info → ipykernel_helper-0.0.4.dist-info}/WHEEL +0 -0
- {ipykernel_helper-0.0.2.dist-info → ipykernel_helper-0.0.4.dist-info}/entry_points.txt +0 -0
- {ipykernel_helper-0.0.2.dist-info → ipykernel_helper-0.0.4.dist-info}/licenses/LICENSE +0 -0
- {ipykernel_helper-0.0.2.dist-info → ipykernel_helper-0.0.4.dist-info}/top_level.txt +0 -0
ipykernel_helper/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.0.
|
|
1
|
+
__version__ = "0.0.4"
|
|
2
2
|
from .core import *
|
ipykernel_helper/_modidx.py
CHANGED
|
@@ -5,14 +5,23 @@ d = { 'settings': { 'branch': 'main',
|
|
|
5
5
|
'doc_host': 'https://AnswerDotAI.github.io',
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/ipykernel-helper',
|
|
7
7
|
'lib_path': 'ipykernel_helper'},
|
|
8
|
-
'syms': { 'ipykernel_helper.core': { 'ipykernel_helper.core.
|
|
9
|
-
|
|
8
|
+
'syms': { 'ipykernel_helper.core': { 'ipykernel_helper.core.InteractiveShell.get_schemas': ( 'core.html#interactiveshell.get_schemas',
|
|
9
|
+
'ipykernel_helper/core.py'),
|
|
10
|
+
'ipykernel_helper.core.InteractiveShell.get_vars': ( 'core.html#interactiveshell.get_vars',
|
|
11
|
+
'ipykernel_helper/core.py'),
|
|
12
|
+
'ipykernel_helper.core.InteractiveShell.publish': ( 'core.html#interactiveshell.publish',
|
|
13
|
+
'ipykernel_helper/core.py'),
|
|
14
|
+
'ipykernel_helper.core.InteractiveShell.ranked_complete': ( 'core.html#interactiveshell.ranked_complete',
|
|
15
|
+
'ipykernel_helper/core.py'),
|
|
16
|
+
'ipykernel_helper.core.InteractiveShell.sig_help': ( 'core.html#interactiveshell.sig_help',
|
|
17
|
+
'ipykernel_helper/core.py'),
|
|
18
|
+
'ipykernel_helper.core.InteractiveShell.user_items': ( 'core.html#interactiveshell.user_items',
|
|
19
|
+
'ipykernel_helper/core.py'),
|
|
20
|
+
'ipykernel_helper.core.InteractiveShell.xpush': ( 'core.html#interactiveshell.xpush',
|
|
21
|
+
'ipykernel_helper/core.py'),
|
|
10
22
|
'ipykernel_helper.core._get_schema': ('core.html#_get_schema', 'ipykernel_helper/core.py'),
|
|
11
23
|
'ipykernel_helper.core._rank': ('core.html#_rank', 'ipykernel_helper/core.py'),
|
|
12
24
|
'ipykernel_helper.core._signatures': ('core.html#_signatures', 'ipykernel_helper/core.py'),
|
|
13
|
-
'ipykernel_helper.core.
|
|
14
|
-
|
|
15
|
-
'ipykernel_helper.core.
|
|
16
|
-
'ipykernel_helper.core.safe_repr': ('core.html#safe_repr', 'ipykernel_helper/core.py'),
|
|
17
|
-
'ipykernel_helper.core.sig_help': ('core.html#sig_help', 'ipykernel_helper/core.py'),
|
|
18
|
-
'ipykernel_helper.core.user_items': ('core.html#user_items', 'ipykernel_helper/core.py')}}}
|
|
25
|
+
'ipykernel_helper.core.load_ipython_extension': ( 'core.html#load_ipython_extension',
|
|
26
|
+
'ipykernel_helper/core.py'),
|
|
27
|
+
'ipykernel_helper.core.safe_repr': ('core.html#safe_repr', 'ipykernel_helper/core.py')}}}
|
ipykernel_helper/core.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto 0
|
|
6
|
-
__all__ = ['safe_repr', '
|
|
6
|
+
__all__ = ['safe_repr', 'load_ipython_extension']
|
|
7
7
|
|
|
8
8
|
# %% ../nbs/00_core.ipynb
|
|
9
9
|
from fastcore.meta import delegates
|
|
@@ -12,12 +12,17 @@ import typing,warnings
|
|
|
12
12
|
from types import ModuleType, FunctionType, MethodType, BuiltinFunctionType
|
|
13
13
|
from inspect import signature, currentframe
|
|
14
14
|
from functools import cmp_to_key,partial
|
|
15
|
+
from collections.abc import Mapping
|
|
15
16
|
from toolslm.funccall import *
|
|
16
17
|
|
|
17
18
|
from jupyter_client import AsyncKernelClient
|
|
19
|
+
from IPython.core.interactiveshell import InteractiveShell
|
|
18
20
|
from IPython.core.completer import ProvisionalCompleterWarning
|
|
19
21
|
from jedi import Interpreter, Script as jscript
|
|
20
22
|
|
|
23
|
+
from IPython.core.display import DisplayObject
|
|
24
|
+
from IPython.display import display,Markdown,HTML
|
|
25
|
+
|
|
21
26
|
# %% ../nbs/00_core.ipynb
|
|
22
27
|
warnings.filterwarnings('ignore', category=ProvisionalCompleterWarning)
|
|
23
28
|
|
|
@@ -30,10 +35,11 @@ def safe_repr(obj, max_len=200):
|
|
|
30
35
|
except Exception as e: return f"<repr error: {str(e)}>"
|
|
31
36
|
|
|
32
37
|
# %% ../nbs/00_core.ipynb
|
|
33
|
-
|
|
38
|
+
@patch
|
|
39
|
+
def user_items(self:InteractiveShell, max_len=200, xtra_skip=()):
|
|
34
40
|
"Get user-defined vars & funcs from namespace."
|
|
35
|
-
|
|
36
|
-
ignore = {'
|
|
41
|
+
ns,nsh = self.user_ns,self.user_ns_hidden
|
|
42
|
+
ignore = {'nbmeta', 'receive_nbmeta'}
|
|
37
43
|
ignore.add(xtra_skip)
|
|
38
44
|
rm_types = (
|
|
39
45
|
type, FunctionType, ModuleType, MethodType, BuiltinFunctionType,
|
|
@@ -42,23 +48,13 @@ def user_items(ns=None, max_len=200, xtra_skip=()):
|
|
|
42
48
|
getattr(typing, '_SpecialForm', ())
|
|
43
49
|
)
|
|
44
50
|
user_items = {k:v for k, v in ns.items()
|
|
45
|
-
if not k in ignore}
|
|
51
|
+
if not k in ignore and k not in nsh}
|
|
46
52
|
user_vars = {k:safe_repr(v, max_len=max_len)
|
|
47
53
|
for k, v in user_items.items() if not k.startswith('_') and not isinstance(v, rm_types)}
|
|
48
54
|
user_fns = {k:str(signature(v)) for k, v in user_items.items()
|
|
49
55
|
if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
|
|
50
56
|
return user_vars,user_fns
|
|
51
57
|
|
|
52
|
-
# %% ../nbs/00_core.ipynb
|
|
53
|
-
@patch
|
|
54
|
-
@delegates(AsyncKernelClient.execute_interactive)
|
|
55
|
-
async def interactive(self:AsyncKernelClient, code:str, **kwargs):
|
|
56
|
-
"Like AsyncKernelClient.execute_interactive, but also returns outputs"
|
|
57
|
-
outputs = []
|
|
58
|
-
def _h(msg: dict): outputs.append(msg)
|
|
59
|
-
res = await self.execute_interactive(code, output_hook=_h, **kwargs)
|
|
60
|
-
return res,outputs
|
|
61
|
-
|
|
62
58
|
# %% ../nbs/00_core.ipynb
|
|
63
59
|
def _rank(c, s):
|
|
64
60
|
"Rank a completion `c` for text `s` with namespace `ns`."
|
|
@@ -72,18 +68,20 @@ def _rank(c, s):
|
|
|
72
68
|
return r if is_public else r+0.1
|
|
73
69
|
|
|
74
70
|
# %% ../nbs/00_core.ipynb
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
@patch
|
|
72
|
+
def ranked_complete(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
73
|
+
ns = self.user_ns
|
|
77
74
|
lines = code.splitlines(True)
|
|
78
75
|
if line_no: offset = sum(len(lines[i]) for i in range(line_no-1)) + col_no -1
|
|
79
76
|
else: offset = len(code)
|
|
80
|
-
cs =
|
|
77
|
+
cs = self.Completer.completions(code, offset)
|
|
81
78
|
def _c(a):
|
|
82
79
|
res = dict2obj({attr: getattr(a, attr) for attr in dir(a) if attr[0]!='_'})
|
|
83
|
-
res['mod']= getattr(
|
|
80
|
+
res['mod']= getattr(ns.get(a.text, None), '__module__', None)
|
|
84
81
|
res['rank'] = _rank(res, s=code)
|
|
85
82
|
return res
|
|
86
|
-
|
|
83
|
+
# Remove dunder vars, unless the user seems to be looking for them explicitly
|
|
84
|
+
return [_c(c) for c in cs if not c.text.startswith('__') or '__' in code]
|
|
87
85
|
|
|
88
86
|
# %% ../nbs/00_core.ipynb
|
|
89
87
|
def _signatures(ns, s, line, col):
|
|
@@ -91,17 +89,19 @@ def _signatures(ns, s, line, col):
|
|
|
91
89
|
if not ctx: ctx = jscript(s).get_signatures(line, col)
|
|
92
90
|
return ctx
|
|
93
91
|
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
@patch
|
|
93
|
+
def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
94
|
+
ns = self.user_ns
|
|
96
95
|
ctx = _signatures(ns, code, line=line_no, col=col_no)
|
|
97
96
|
def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
|
|
98
97
|
'idx':s.index, 'params':[{'name':p.name} for p in s.params]}
|
|
99
98
|
return [_s(opt) for opt in ctx]
|
|
100
99
|
|
|
101
100
|
# %% ../nbs/00_core.ipynb
|
|
102
|
-
|
|
101
|
+
@patch
|
|
102
|
+
def get_vars(self:InteractiveShell, vs:list):
|
|
103
103
|
"Get variables from namespace."
|
|
104
|
-
ns =
|
|
104
|
+
ns = self.user_ns
|
|
105
105
|
return {v:ns[v] for v in vs if v in ns}
|
|
106
106
|
|
|
107
107
|
# %% ../nbs/00_core.ipynb
|
|
@@ -111,7 +111,24 @@ def _get_schema(ns: dict, t):
|
|
|
111
111
|
try: return get_schema(ns[t])
|
|
112
112
|
except Exception as e: return f"`{t}`: {e}."
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
@patch
|
|
115
|
+
def get_schemas(self:InteractiveShell, fs:list):
|
|
115
116
|
"Get schemas from namespace."
|
|
116
|
-
ns =
|
|
117
|
+
ns = self.user_ns
|
|
117
118
|
return {f:_get_schema(ns,f) for f in fs}
|
|
119
|
+
|
|
120
|
+
# %% ../nbs/00_core.ipynb
|
|
121
|
+
@patch
|
|
122
|
+
def xpush(self:InteractiveShell, interactive=False, **kw):
|
|
123
|
+
"Like `push`, but with kwargs"
|
|
124
|
+
self.push(kw, interactive=interactive)
|
|
125
|
+
|
|
126
|
+
# %% ../nbs/00_core.ipynb
|
|
127
|
+
@patch
|
|
128
|
+
def publish(self:InteractiveShell, data='', subtype='plain', mimetype='text', meta=None, update=False, **kw):
|
|
129
|
+
if isinstance(data, DisplayObject): data,_ = self.display_formatter.format(data)
|
|
130
|
+
elif not isinstance(data, Mapping): data = {f'{mimetype}/{subtype}': data}
|
|
131
|
+
self.display_pub.publish(data, metadata=meta, transient=kw, update=update)
|
|
132
|
+
|
|
133
|
+
# %% ../nbs/00_core.ipynb
|
|
134
|
+
def load_ipython_extension(ip): import ipykernel_helper as __ipykernel_helper
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
ipykernel_helper/__init__.py,sha256=aeFr0PgPk9_EeMwvlUatX5uddiE_ZoYCKQ5DBD_vHbQ,42
|
|
2
|
+
ipykernel_helper/_modidx.py,sha256=nv-MIlyO6uBIKYgQvQrmyjr2nuOs1o4lN8rL5DTJu-o,2845
|
|
3
|
+
ipykernel_helper/core.py,sha256=tQSFMU3I6f_W5gjqq2RwPmqyUES_4OuaSmXFr7Uc9Jc,5094
|
|
4
|
+
ipykernel_helper-0.0.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
+
ipykernel_helper-0.0.4.dist-info/METADATA,sha256=VI3V_HHjjLpWxg-sBjWeAAaUtq18OnKVc6Tbva5wycE,2557
|
|
6
|
+
ipykernel_helper-0.0.4.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
7
|
+
ipykernel_helper-0.0.4.dist-info/entry_points.txt,sha256=HWiK9xz75QtZUaPaYrwpyH5B8MbW0Ea_vi11UmwBImM,54
|
|
8
|
+
ipykernel_helper-0.0.4.dist-info/top_level.txt,sha256=_diD--64d9MauLE0pTxzZ58lkI8DvCrVc1hVAJsyc_Q,17
|
|
9
|
+
ipykernel_helper-0.0.4.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
ipykernel_helper/__init__.py,sha256=oDLMnoGVIAzRy6kwJGpxSDGyOG-aI7DiiERW6jGauWk,42
|
|
2
|
-
ipykernel_helper/_modidx.py,sha256=juRUbLKiU68mB88Ehn5cMLD2REiCSWOQd9BTdeDQz4Y,1727
|
|
3
|
-
ipykernel_helper/core.py,sha256=UpePoI_QbKQM2BjJ3sQ-_54tdFaHHDfLHmSPmu4i7V4,4494
|
|
4
|
-
ipykernel_helper-0.0.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
-
ipykernel_helper-0.0.2.dist-info/METADATA,sha256=xuDKpEG0317k8OoE-_16n2gkthww1fotP4mPVVmZnLI,2557
|
|
6
|
-
ipykernel_helper-0.0.2.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
7
|
-
ipykernel_helper-0.0.2.dist-info/entry_points.txt,sha256=HWiK9xz75QtZUaPaYrwpyH5B8MbW0Ea_vi11UmwBImM,54
|
|
8
|
-
ipykernel_helper-0.0.2.dist-info/top_level.txt,sha256=_diD--64d9MauLE0pTxzZ58lkI8DvCrVc1hVAJsyc_Q,17
|
|
9
|
-
ipykernel_helper-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|