Skip to content

Commit 0bdfd0b

Browse files
author
Ahmed Fasih
committed
Make backwards-compatible
There are two options suggested in #809: 1. use TypeError to catch non-existent omit_sections kw. This will work with master but will be less clear when we deprecate IPython 7.x in a few years. 2. use IPython version_info, which makes cleanup easier but means we won't be able to use this feature with master IPython, only v8. Going with #2 because it's cleaner.
1 parent 77cdd28 commit 0bdfd0b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ipykernel/ipkernel.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from contextlib import contextmanager
66
from functools import partial
77
import getpass
8+
import re
89
import signal
910
import sys
1011

@@ -466,13 +467,20 @@ def do_inspect(self, code, cursor_pos, detail_level=0, omit_sections=()):
466467
reply_content['data'] = {}
467468
reply_content['metadata'] = {}
468469
try:
469-
reply_content['data'].update(
470-
self.shell.object_inspect_mime(
470+
if release.version_info >= (8,):
471+
# `omit_sections` keyword will be available in IPython 8, see
472+
# https://github.com/ipython/ipython/pull/13343
473+
bundle = self.shell.object_inspect_mime(
471474
name,
472475
detail_level=detail_level,
473476
omit_sections=omit_sections,
474477
)
475-
)
478+
else:
479+
bundle = self.shell.object_inspect_mime(
480+
name,
481+
detail_level=detail_level
482+
)
483+
reply_content['data'].update(bundle)
476484
if not self.shell.enable_html_pager:
477485
reply_content['data'].pop('text/html')
478486
reply_content['found'] = True

0 commit comments

Comments
 (0)