Skip to content

Commit c9cfab5

Browse files
committed
fixes #74
1 parent 217894e commit c9cfab5

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed

execnb/_modidx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
'execnb.shell.CaptureShell.set_path': ('shell.html#captureshell.set_path', 'execnb/shell.py'),
3636
'execnb.shell.ExecutionInfo.__repr__': ('shell.html#executioninfo.__repr__', 'execnb/shell.py'),
3737
'execnb.shell.ExecutionResult.__repr__': ('shell.html#executionresult.__repr__', 'execnb/shell.py'),
38+
'execnb.shell.NbResult': ('shell.html#nbresult', 'execnb/shell.py'),
3839
'execnb.shell.SmartCompleter': ('shell.html#smartcompleter', 'execnb/shell.py'),
3940
'execnb.shell.SmartCompleter.__call__': ('shell.html#smartcompleter.__call__', 'execnb/shell.py'),
4041
'execnb.shell.SmartCompleter.__init__': ('shell.html#smartcompleter.__init__', 'execnb/shell.py'),

execnb/shell.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535

3636
# %% auto 0
37-
__all__ = ['CaptureShell', 'format_exc', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error', 'exec_nb',
38-
'SmartCompleter']
37+
__all__ = ['CaptureShell', 'format_exc', 'NbResult', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error',
38+
'exec_nb', 'SmartCompleter']
3939

4040
# %% ../nbs/02_shell.ipynb
4141
class _CustDisplayHook(DisplayHook):
@@ -102,6 +102,9 @@ def format_exc(e):
102102
"Format exception `e` as a string list"
103103
return traceback.format_exception(type(e), e, e.__traceback__)
104104

105+
# %% ../nbs/02_shell.ipynb
106+
class NbResult(list): pass
107+
105108
# %% ../nbs/02_shell.ipynb
106109
def _out_stream(text, name): return dict(name=name, output_type='stream', text=text.splitlines(True))
107110
def _out_exc(e):
@@ -122,13 +125,15 @@ def _mk_out(data, meta, output_type='display_data'):
122125
return dict(data=fd, metadata=meta, output_type=output_type)
123126

124127
def _out_nb(o, fmt):
125-
res = []
128+
res = NbResult()
126129
if o.stdout: res.append(_out_stream(o.stdout, 'stdout'))
127130
if o.stderr: res.append(_out_stream(o.stderr, 'stderr'))
128131
if o.exception: res.append(_out_exc(o.exception))
129132
r = o.result.result
133+
if hasattr(r, '__ft__'): r = r.__ft__()
134+
res.result = r
130135
for x in o.display_objects: res.append(_mk_out(x.data, x.metadata))
131-
if r is not None and not o.quiet:
136+
if r is not None and not o.quiet and not isinstance_str(r, 'FT'):
132137
res.append(_mk_out(*fmt.format(r), 'execute_result'))
133138
if 'execution_count' not in o: o['execution_count']=None
134139
for p in res:

nbs/02_shell.ipynb

Lines changed: 45 additions & 26 deletions
Large diffs are not rendered by default.

nbs/nbdev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ website:
55
title: "execnb"
66
site-url: "https://AnswerDotAI.github.io/execnb/"
77
description: "A description of your project"
8-
repo-branch: master
8+
repo-branch: main
99
repo-url: "https://github.com/AnswerDotAI/execnb/"

0 commit comments

Comments
 (0)