diff --git a/google/colab/_inspector.py b/google/colab/_inspector.py index ef59a7cf..15e4358c 100644 --- a/google/colab/_inspector.py +++ b/google/colab/_inspector.py @@ -582,6 +582,7 @@ def info(self, obj, oname='', formatter=None, info=None, detail_level=0): if filename and ( filename.endswith(('.py', '.py3', '.pyc')) or 'ipython-input-' in filename + or 'ipykernel_' in filename ): out['file'] = filename diff --git a/google/colab/_reprs.py b/google/colab/_reprs.py index 982fcb2b..5d0c8bc7 100644 --- a/google/colab/_reprs.py +++ b/google/colab/_reprs.py @@ -286,7 +286,8 @@ def _function_repr(obj): ) result += html.escape(docs) + '' - if filename and 'ipython-input' not in filename: + jupyter_paths = ('ipython-input', 'ipykernel_') + if filename and all(path not in filename for path in jupyter_paths): line = oinspect.find_source_lines(obj) result += f"""