Skip to content

Commit c2cac3b

Browse files
committed
bug fixes and warnings
1 parent 51983c2 commit c2cac3b

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

execnb/shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from .nbio import *
3333
from .nbio import _dict2obj
3434

35+
3536
# %% auto 0
3637
__all__ = ['CaptureShell', 'format_exc', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error', 'exec_nb',
3738
'SmartCompleter']
@@ -274,7 +275,7 @@ def prettytb(self:CaptureShell,
274275
fname = fname if fname else self._fname
275276
_fence = '='*75
276277
cell_intro_str = f"While Executing Cell #{self._cell_idx}:" if self._cell_idx else "While Executing:"
277-
cell_str = f"\n{cell_intro_str}\n{format_exc(self.exc)}"
278+
cell_str = f"\n{cell_intro_str}\n{''.join(format_exc(self.exc))}"
278279
fname_str = f' in {fname}' if fname else ''
279280
return f"{type(self.exc).__name__}{fname_str}:\n{_fence}\n{cell_str}\n"
280281

nbs/02_shell.ipynb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"\n",
5454
"\n",
5555
"from execnb.nbio import *\n",
56-
"from execnb.nbio import _dict2obj"
56+
"from execnb.nbio import _dict2obj\n"
5757
]
5858
},
5959
{
@@ -779,8 +779,8 @@
779779
"text/plain": [
780780
"[{'name': 'stdout',\n",
781781
" 'output_type': 'stream',\n",
782-
" 'text': ['CPU times: user 2 us, sys: 0 ns, total: 2 us\\n',\n",
783-
" 'Wall time: 1.91 us\\n']},\n",
782+
" 'text': ['CPU times: user 1 us, sys: 1 us, total: 2 us\\n',\n",
783+
" 'Wall time: 3.1 us\\n']},\n",
784784
" {'data': {'text/plain': ['2']},\n",
785785
" 'metadata': {},\n",
786786
" 'output_type': 'execute_result',\n",
@@ -900,7 +900,9 @@
900900
"outputs": [],
901901
"source": [
902902
"from IPython.core.ultratb import VerboseTB\n",
903-
"formatter = VerboseTB(theme_name='linux')"
903+
"with warnings.catch_warnings():\n",
904+
" warnings.filterwarnings(\"ignore\", category=DeprecationWarning)\n",
905+
" formatter = VerboseTB(color_scheme='Linux')"
904906
]
905907
},
906908
{
@@ -1797,7 +1799,7 @@
17971799
" fname = fname if fname else self._fname\n",
17981800
" _fence = '='*75\n",
17991801
" cell_intro_str = f\"While Executing Cell #{self._cell_idx}:\" if self._cell_idx else \"While Executing:\"\n",
1800-
" cell_str = f\"\\n{cell_intro_str}\\n{format_exc(self.exc)}\"\n",
1802+
" cell_str = f\"\\n{cell_intro_str}\\n{''.join(format_exc(self.exc))}\"\n",
18011803
" fname_str = f' in {fname}' if fname else ''\n",
18021804
" return f\"{type(self.exc).__name__}{fname_str}:\\n{_fence}\\n{cell_str}\\n\""
18031805
]
@@ -1822,7 +1824,23 @@
18221824
"===========================================================================\n",
18231825
"\n",
18241826
"While Executing Cell #2:\n",
1825-
"['Traceback (most recent call last):\\n', ' File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_97767/1421292703.py\", line 3, in <module>\\n s.execute(\\'../tests/error.ipynb\\', exc_stop=True)\\n', ' File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_97767/3609882568.py\", line 18, in execute\\n self.run_all(nb, exc_stop=exc_stop, preproc=preproc, postproc=postproc,\\n', ' File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_97767/3068237356.py\", line 19, in run_all\\n if self.exc and exc_stop: raise self.exc from None\\n ^^^^^^^^^^^^^^^^^^^^^^^^\\n', ' File \"/Users/iflath/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3546, in run_code\\n exec(code_obj, self.user_global_ns, self.user_ns)\\n', ' File \"<ipython-input-1-b968a57a586e>\", line 3, in <module>\\n foo()\\n', ' File \"/Users/iflath/git/fastai/execnb/tests/err.py\", line 2, in foo\\n assert 13 == 98\\n ^^^^^^^^\\n', 'AssertionError\\n']\n",
1827+
"Traceback (most recent call last):\n",
1828+
" File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_8573/1421292703.py\", line 3, in <module>\n",
1829+
" s.execute('../tests/error.ipynb', exc_stop=True)\n",
1830+
" File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_8573/3609882568.py\", line 18, in execute\n",
1831+
" self.run_all(nb, exc_stop=exc_stop, preproc=preproc, postproc=postproc,\n",
1832+
" File \"/var/folders/_8/cpj54rdn0w1fjskv7g8bn2fr0000gn/T/ipykernel_8573/3068237356.py\", line 19, in run_all\n",
1833+
" if self.exc and exc_stop: raise self.exc from None\n",
1834+
" ^^^^^^^^^^^^^^^^^^^^^^^^\n",
1835+
" File \"/Users/iflath/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3546, in run_code\n",
1836+
" exec(code_obj, self.user_global_ns, self.user_ns)\n",
1837+
" File \"<ipython-input-1-b968a57a586e>\", line 3, in <module>\n",
1838+
" foo()\n",
1839+
" File \"/Users/iflath/git/fastai/execnb/tests/err.py\", line 2, in foo\n",
1840+
" assert 13 == 98\n",
1841+
" ^^^^^^^^\n",
1842+
"AssertionError\n",
1843+
"\n",
18261844
"\n"
18271845
]
18281846
}

0 commit comments

Comments
 (0)