Search code examples
pythonipythonread-eval-print-loop

Turn off "on the fly" reformatting of code in IPython REPL


Starting with IPython 8.0, the code I type in the REPL is reformatted automagically.

As it happens (and I realize it's my fault), I am confused by this behavior. If I had the choice between getting accustomed to this new experience and turning it off, I'd choose option no. 2.

How can I turn off the "on the fly" reformatting in IPython 8.0?


Solution

  • IPython supports a couple configuration methods, with profiles being the most common. You can create the default profile configuration file by running ipython profile create which will create a ipython_config.py file under .ipython in your home dir.

    In there you can find a commented entry for

    c.TerminalInteractiveShell.autoformatter = None
    

    either uncomment this, or set it to None yourself and black will no longer be automatically applied to the code.

    If modifying the profile's config is not viable the other options are documented here.