Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/IPython/core/getipython.py: 50%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

8 statements  

1"""Simple function to call to get the current InteractiveShell instance""" 

2 

3# ----------------------------------------------------------------------------- 

4# Copyright (C) 2013 The IPython Development Team 

5# 

6# Distributed under the terms of the BSD License. The full license is in 

7# the file COPYING, distributed as part of this software. 

8# ----------------------------------------------------------------------------- 

9 

10# ----------------------------------------------------------------------------- 

11# Classes and functions 

12# ----------------------------------------------------------------------------- 

13from typing import TYPE_CHECKING 

14 

15if TYPE_CHECKING: 

16 from IPython.core.interactiveshell import InteractiveShell 

17 

18 

19def get_ipython() -> "InteractiveShell | None": 

20 """Get the global InteractiveShell instance. 

21 

22 Returns None if no InteractiveShell instance is registered. 

23 """ 

24 from IPython.core.interactiveshell import InteractiveShell 

25 

26 if InteractiveShell.initialized(): 

27 return InteractiveShell.instance()