ipykernel-helper 0.0.35__tar.gz → 0.0.37__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.
- {ipykernel_helper-0.0.35/ipykernel_helper.egg-info → ipykernel_helper-0.0.37}/PKG-INFO +1 -1
- ipykernel_helper-0.0.37/ipykernel_helper/__init__.py +2 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper/_modidx.py +5 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper/core.py +63 -24
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37/ipykernel_helper.egg-info}/PKG-INFO +1 -1
- ipykernel_helper-0.0.35/ipykernel_helper/__init__.py +0 -2
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/LICENSE +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/MANIFEST.in +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/README.md +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/SOURCES.txt +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/dependency_links.txt +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/entry_points.txt +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/requires.txt +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/top_level.txt +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/pyproject.toml +0 -0
- {ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/setup.cfg +0 -0
|
@@ -9,6 +9,10 @@ d = { 'settings': { 'branch': 'main',
|
|
|
9
9
|
'ipykernel_helper/core.py'),
|
|
10
10
|
'ipykernel_helper.core.Inspector._get_info': ( 'core.html#inspector._get_info',
|
|
11
11
|
'ipykernel_helper/core.py'),
|
|
12
|
+
'ipykernel_helper.core.InteractiveShell._sig_dyn': ( 'core.html#interactiveshell._sig_dyn',
|
|
13
|
+
'ipykernel_helper/core.py'),
|
|
14
|
+
'ipykernel_helper.core.InteractiveShell._sig_jedi': ( 'core.html#interactiveshell._sig_jedi',
|
|
15
|
+
'ipykernel_helper/core.py'),
|
|
12
16
|
'ipykernel_helper.core.InteractiveShell.eval_exprs': ( 'core.html#interactiveshell.eval_exprs',
|
|
13
17
|
'ipykernel_helper/core.py'),
|
|
14
18
|
'ipykernel_helper.core.InteractiveShell.get_schemas': ( 'core.html#interactiveshell.get_schemas',
|
|
@@ -38,6 +42,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
38
42
|
'ipykernel_helper.core._get_math_mode': ('core.html#_get_math_mode', 'ipykernel_helper/core.py'),
|
|
39
43
|
'ipykernel_helper.core._get_schema': ('core.html#_get_schema', 'ipykernel_helper/core.py'),
|
|
40
44
|
'ipykernel_helper.core._maybe_eval': ('core.html#_maybe_eval', 'ipykernel_helper/core.py'),
|
|
45
|
+
'ipykernel_helper.core._param_idx': ('core.html#_param_idx', 'ipykernel_helper/core.py'),
|
|
41
46
|
'ipykernel_helper.core._rank': ('core.html#_rank', 'ipykernel_helper/core.py'),
|
|
42
47
|
'ipykernel_helper.core._safe_repr': ('core.html#_safe_repr', 'ipykernel_helper/core.py'),
|
|
43
48
|
'ipykernel_helper.core._signatures': ('core.html#_signatures', 'ipykernel_helper/core.py'),
|
|
@@ -12,7 +12,7 @@ from fastcore.meta import delegates
|
|
|
12
12
|
from fastcore.utils import patch,dict2obj
|
|
13
13
|
from fastcore.docments import sig_source,DocmentText
|
|
14
14
|
from fastcore.net import HTTP404NotFoundError
|
|
15
|
-
from fastcore.xtras import truncstr
|
|
15
|
+
from fastcore.xtras import truncstr,maybe_await
|
|
16
16
|
from types import ModuleType, FunctionType, MethodType, BuiltinFunctionType
|
|
17
17
|
from inspect import signature, currentframe
|
|
18
18
|
from functools import cmp_to_key,partial
|
|
@@ -24,8 +24,9 @@ from toolslm.xml import *
|
|
|
24
24
|
from ast import literal_eval
|
|
25
25
|
from urllib.parse import urlparse, urljoin
|
|
26
26
|
from ghapi.all import GhApi
|
|
27
|
+
from io import StringIO
|
|
27
28
|
|
|
28
|
-
import typing,warnings,re,os,html2text,base64,inspect,traceback
|
|
29
|
+
import typing,warnings,re,os,html2text,base64,inspect,traceback,tokenize
|
|
29
30
|
|
|
30
31
|
from IPython.core.interactiveshell import InteractiveShell
|
|
31
32
|
from IPython.core.completer import ProvisionalCompleterWarning
|
|
@@ -95,33 +96,19 @@ def ranked_complete(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
|
95
96
|
# Remove dunder vars, unless the user seems to be looking for them explicitly
|
|
96
97
|
return [_c(c) for c in cs if not c.text.startswith('__') or '__' in code]
|
|
97
98
|
|
|
98
|
-
# %% ../nbs/00_core.ipynb #
|
|
99
|
-
def _signatures(ns, s, line, col):
|
|
100
|
-
ctx = Interpreter(s, [ns]).get_signatures(line, col)
|
|
101
|
-
if not ctx: ctx = jscript(s).get_signatures(line, col)
|
|
102
|
-
return ctx
|
|
103
|
-
|
|
104
|
-
@patch
|
|
105
|
-
def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
106
|
-
ns = self.user_ns
|
|
107
|
-
ctx = _signatures(ns, code, line=line_no, col=col_no)
|
|
108
|
-
def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
|
|
109
|
-
'idx':s.index, 'params':[{'name':p.name, 'desc':p.description} for p in s.params]}
|
|
110
|
-
return [_s(opt) for opt in ctx]
|
|
111
|
-
|
|
112
|
-
# %% ../nbs/00_core.ipynb #808cd4c5
|
|
99
|
+
# %% ../nbs/00_core.ipynb #192310a4
|
|
113
100
|
def _maybe_eval(o):
|
|
114
101
|
try: literal_eval(repr(o)); return o
|
|
115
102
|
except: return str(o)
|
|
116
103
|
|
|
117
|
-
# %% ../nbs/00_core.ipynb #
|
|
104
|
+
# %% ../nbs/00_core.ipynb #b3613f76
|
|
118
105
|
@patch
|
|
119
106
|
def get_vars(self:InteractiveShell, vs:list, literal=True):
|
|
120
107
|
"Get variables from namespace."
|
|
121
108
|
ns = self.user_ns
|
|
122
109
|
return {v:_maybe_eval(ns[v]) if literal else str(ns[v]) for v in vs if v in ns}
|
|
123
110
|
|
|
124
|
-
# %% ../nbs/00_core.ipynb #
|
|
111
|
+
# %% ../nbs/00_core.ipynb #ed89fa06
|
|
125
112
|
@patch
|
|
126
113
|
def eval_exprs(self:InteractiveShell, vs:list, literal=True):
|
|
127
114
|
"Evaluate expressions in namespace."
|
|
@@ -131,7 +118,7 @@ def eval_exprs(self:InteractiveShell, vs:list, literal=True):
|
|
|
131
118
|
except Exception as e: res[v] = f'<error type="{type(e).__name__}" desc="{e}">\n{traceback.format_exc()}</error>'
|
|
132
119
|
return res
|
|
133
120
|
|
|
134
|
-
# %% ../nbs/00_core.ipynb #
|
|
121
|
+
# %% ../nbs/00_core.ipynb #d4195d94
|
|
135
122
|
def _get_schema(ns: dict, t):
|
|
136
123
|
"Check if tool `t` has errors."
|
|
137
124
|
try: schema = get_schema_nm(t, ns, pname='parameters', evalable=True, skip_hidden=True, dot2dash=True)
|
|
@@ -144,12 +131,66 @@ def get_schemas(self:InteractiveShell, fs:list):
|
|
|
144
131
|
"Get schemas from namespace."
|
|
145
132
|
return {f:_get_schema(self.user_ns, f) for f in fs}
|
|
146
133
|
|
|
147
|
-
# %% ../nbs/00_core.ipynb #
|
|
134
|
+
# %% ../nbs/00_core.ipynb #281193c9
|
|
148
135
|
@patch
|
|
149
136
|
def xpush(self:InteractiveShell, interactive=False, **kw):
|
|
150
137
|
"Like `push`, but with kwargs"
|
|
151
138
|
self.push(kw, interactive=interactive)
|
|
152
139
|
|
|
140
|
+
# %% ../nbs/00_core.ipynb #50ec6221
|
|
141
|
+
def _signatures(ns, s, line, col):
|
|
142
|
+
ctx = Interpreter(s, [ns]).get_signatures(line, col)
|
|
143
|
+
if not ctx: ctx = jscript(s).get_signatures(line, col)
|
|
144
|
+
return ctx
|
|
145
|
+
|
|
146
|
+
@patch
|
|
147
|
+
def _sig_jedi(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
148
|
+
ns = self.user_ns
|
|
149
|
+
ctx = _signatures(ns, code, line=line_no, col=col_no)
|
|
150
|
+
if ctx:
|
|
151
|
+
def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
|
|
152
|
+
'idx':s.index, 'params':[{'name':p.name, 'desc':p.description} for p in s.params]}
|
|
153
|
+
return [_s(opt) for opt in ctx]
|
|
154
|
+
return []
|
|
155
|
+
|
|
156
|
+
# %% ../nbs/00_core.ipynb #a7fa20ce
|
|
157
|
+
def _param_idx(code, cursor_pos):
|
|
158
|
+
toks = []
|
|
159
|
+
def op(s): return s == tokenize.OP
|
|
160
|
+
g = tokenize.generate_tokens(StringIO(code[:cursor_pos]).readline)
|
|
161
|
+
while True:
|
|
162
|
+
try: toks.append(next(g))
|
|
163
|
+
except (tokenize.TokenError, StopIteration): break
|
|
164
|
+
depth,idx = 0,0
|
|
165
|
+
for t in reversed(toks):
|
|
166
|
+
if op(t.type) and t.string in ')]}': depth += 1
|
|
167
|
+
elif op(t.type) and t.string in '([{':
|
|
168
|
+
if depth == 0: return idx
|
|
169
|
+
depth -= 1
|
|
170
|
+
elif op(t.type) and t.string == ',' and depth == 0: idx += 1
|
|
171
|
+
return 0
|
|
172
|
+
|
|
173
|
+
# %% ../nbs/00_core.ipynb #af7f189f
|
|
174
|
+
@patch
|
|
175
|
+
def _sig_dyn(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
176
|
+
from IPython.utils.tokenutil import token_at_cursor
|
|
177
|
+
lines = code.splitlines()
|
|
178
|
+
cursor_pos = sum(len(l)+1 for l in lines[:line_no-1])+col_no if line_no else len(code)
|
|
179
|
+
name = token_at_cursor(code, cursor_pos)
|
|
180
|
+
info = self._object_find(name)
|
|
181
|
+
if not (info.found and callable(info.obj)): return []
|
|
182
|
+
try: sig = inspect.signature(info.obj)
|
|
183
|
+
except (ValueError, TypeError): return []
|
|
184
|
+
return [{'label':name, 'typ':type(info.obj).__name__, 'mod':getattr(info.obj,'__module__',''),
|
|
185
|
+
'doc':getattr(info.obj,'__doc__','') or '', 'idx':_param_idx(code, cursor_pos),
|
|
186
|
+
'params':[{'name':p.name, 'desc':str(p)} for p in sig.parameters.values()]}]
|
|
187
|
+
|
|
188
|
+
# %% ../nbs/00_core.ipynb #0c1e6cc7
|
|
189
|
+
@patch
|
|
190
|
+
def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
|
|
191
|
+
"Get signature help for code at cursor position using dynamic analysis or jedi as a backup."
|
|
192
|
+
return self._sig_dyn(code, line_no, col_no=col_no) or self._sig_jedi(code, line_no, col_no=col_no)
|
|
193
|
+
|
|
153
194
|
# %% ../nbs/00_core.ipynb #d4a073da
|
|
154
195
|
@patch
|
|
155
196
|
def publish(self:InteractiveShell, data='', subtype='plain', mimetype='text', meta=None, update=False, **kw):
|
|
@@ -337,8 +378,6 @@ def _await_cell_magic(lines):
|
|
|
337
378
|
return lines
|
|
338
379
|
|
|
339
380
|
def load_ipython_extension(ip):
|
|
340
|
-
from ipykernel_helper import transient,run_cmd
|
|
341
|
-
|
|
342
381
|
ns = ip.user_ns
|
|
343
|
-
|
|
382
|
+
for o in ('read_gh_repo','read_url','transient','run_cmd','maybe_await'): ns[o] = globals()[o]
|
|
344
383
|
ip.input_transformer_manager.line_transforms.append(_await_cell_magic)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{ipykernel_helper-0.0.35 → ipykernel_helper-0.0.37}/ipykernel_helper.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|