Skip to content

Commit 2c62bab

Browse files
authored
Removed redundant ipython import which slowed application startup time (#1717)
1 parent 7fa6cbb commit 2c62bab

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Enhancements
44
- Added possibility to use rich Text objects to set the description argument of a `Settable`
5+
- Removed redundant `ipython` import which slowed application startup time
56

67
## 4.1.1 (July 9, 2026)
78

cmd2/cmd2.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@
177177
UnboundCompleter,
178178
)
179179

180-
with contextlib.suppress(ImportError):
181-
from IPython import start_ipython
182-
183180
try:
184181
if sys.platform == "win32":
185182
from prompt_toolkit.output.win32 import NoConsoleScreenBufferError # type: ignore[attr-defined]
@@ -5151,13 +5148,7 @@ def do_ipy(self, _: argparse.Namespace) -> bool | None: # pragma: no cover
51515148
# Detect whether IPython is installed
51525149
try:
51535150
import traitlets.config.loader as traitlets_loader
5154-
5155-
# Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
5156-
try:
5157-
_dummy = start_ipython # noqa: F823
5158-
except NameError:
5159-
from IPython import start_ipython
5160-
5151+
from IPython import start_ipython
51615152
from IPython.terminal.interactiveshell import TerminalInteractiveShell
51625153
from IPython.terminal.ipapp import TerminalIPythonApp
51635154
except ImportError:

0 commit comments

Comments
 (0)