Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable code formatting in ipython?

Tags:

python

ipython

IPython has this new feature that reformats my prompt. Unfortunately, it is really buggy, so I want to disable it. I managed to do it when starting IPython from the command line by adding the following line in my ipython_config.py:

c.TerminalInteractiveShell.autoformatter = None

However, it does not work when I run it from a python script. I start IPython from my script the following way:

c = traitlets.config.get_config()
c.InteractiveShellEmbed.colors = "Linux"
c.TerminalInteractiveShell.autoformatter = None
c.InteractiveShellEmbed.loop_runner = lambda coro: loop.run_until_complete(coro)
IPython.embed(display_banner='', using='asyncio', config=c)

If I change the colors value, the colors change accordingly, so the configuration itself works. However, no matter what I do with autoformatter, IPython autoformats my code regardless. What am I doing wrong?

like image 376
petersohn Avatar asked Jul 03 '26 18:07

petersohn


1 Answers

Apparently, the answer is:

c.InteractiveShellEmbed.autoformatter = None
like image 165
petersohn Avatar answered Jul 06 '26 08:07

petersohn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!