Development version
This document describes in-flight development work.
Warning
Please do not edit this file by hand (doing so will likely cause merge conflicts for other Pull Requests). Instead, create a new file in the docs/source/whatsnew/pr folder
Released .... ...., 2019
Need to be updated:
IPython 8.0 is bringing a large number of new features and improvements to both the user of the terminal and of the kernel via Jupyter. The removal of compatibility with older version of Python is also the opportunity to do a couple of performance improvement in particular with respect to startup time.
This release contains 250+ Pull requests, in addition to many of the features and backports that have made it to the 7.x branch.
We removed almost all features, arguments, functions, and modules that were marked as deprecated between IPython 1.0 and 5.0 and before. As reminder 5.0 was released in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in may 2020. The few remaining deprecated features have better deprecation warnings or errors.
There are many change in IPython 8.0 will will try to describe subsequently,
The first on is the integration of the stack_data package; which provide smarter information in traceback; in particular it will highlight the AST node where an error occurs which can help to quickly narrow down errors.
For example in the following snippet:
def foo(i): x = [[[0]]] return x[0][i][0] def bar(): return foo(0) + foo( 1 ) + foo(2)
Calling bar() would raise an IndexError on the return line of foo, IPython 8.0 is capable of telling you, where the index error occurs:
return x[0][i][0] ^
Numfocus Small Developer Grant
To prepare for Python 3.10 we have also started working on removing reliance and any dependency that is not Python 3.10 compatible; that include migrating our test suite to pytest, and starting to remove nose. This also mean that the iptest command is now gone, and all testing is via pytest.
This was in bog part thanks the NumFOCUS Small Developer grant, we were able to allocate 4000 to hire Nikita Kniazev @Kojoley who did a fantastic job at updating our code base, migrating to pytest, pushing our coverage, and fixing a large number of bugs. I highly recommend contacting them if you need help with C++ and Python projects
You can find all relevant issues and PRs with the SDG 2021 tag:
https://github.com/ipython/ipython/issues?q=label%3A%22Numfocus+SDG+2021%22+
Removing support for Older Python
We are also removing support for Python up to 3.7 allowing internal code to use more efficient pathlib, and make better use of type annotations.
IMAGE : Pathlib, pathlib everywhere.
The completer has also seen significant updates and make use of newer Jedi API offering faster and more reliable tab completion.
For the terminal users this also enable the auto-suggestion feature, described below, which show "ghost text" ahead of your cursor you can accept without having to press the tab key or ask the completer to suggest completions.
Autosuggestion is a very useful feature available in fish, zsh, and prompt-toolkit.
Ptpython allows users to enable this feature in ptpython/config.py.
This feature allows users to accept autosuggestions with ctrl e, ctrl f, or right arrow as described below.
- Start ipython
![../_images/auto_suggest_prompt_no_text.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_prompt_no_text.png)
- Run print("hello")
![../_images/auto_suggest_print_hello_suggest.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_print_hello_suggest.png)
- Press p to see the autosuggestion
![../_images/auto_suggest_print_hello_suggest.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_print_hello_suggest.png)
- Press ctrl f, or ctrl e, or right arrow to accept the suggestion
![../_images/auto_suggest_print_hello.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_print_hello.png)
You can also complete word by word:
- Run def say_hello(): print("hello")
![../_images/auto_suggest_second_prompt.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_second_prompt.png)
- Press d to see the autosuggestion
![../_images/audo_suggest_d_phantom.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/audo_suggest_d_phantom.png)
- Press alt f to accept the first word of the suggestion
![../_images/auto_suggest_def_phantom.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_def_phantom.png)
Importantly, this feature does not interfere with tab completion:
- After running def say_hello(): print("hello"), press d
![../_images/audo_suggest_d_phantom.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/audo_suggest_d_phantom.png)
- Press Tab to start tab completion
![../_images/auto_suggest_d_completions.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_d_completions.png)
3A. Press Tab again to select the first option
![../_images/auto_suggest_def_completions.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_def_completions.png)
3B. Press alt f to accept to accept the first word of the suggestion
![../_images/auto_suggest_def_phantom.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_def_phantom.png)
3C. Press ctrl f or ctrl e to accept the entire suggestion
![../_images/auto_suggest_match_parens.png](/upstream/ipython/raw/cfa7cc7f10cd058fc4f13907e555464bc282df26/docs/source/_images/auto_suggest_match_parens.png)
To install a version of ipython with autosuggestions enabled, run:
pip install git+https://github.com/mskar/ipython@auto_suggest
Currently, autosuggestions are only shown in the emacs or vi insert editing modes:
- The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode.
- To use these shortcuts in vi insert mode, you will have to create custom keybindings in your config.py.
Show pinfo information in ipdb using "?" and "??"
In IPDB, it is now possible to show the information about an object using "?" and "??", in much the same way it can be done when using the IPython prompt:
ipdb> partial? Init signature: partial(self, /, *args, **kwargs) Docstring: partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. File: ~/.pyenv/versions/3.8.6/lib/python3.8/functools.py Type: type Subclasses:
Previously, "pinfo" or "pinfo2" command had to be used for this purpose.
Autoreload 3 feature
Example: When an IPython session is ran with the 'autoreload' extension loaded, you will now have the option '3' to select which means the following:
- replicate all functionality from option 2
- autoload all new funcs/classes/enums/globals from the module when they're added
- autoload all newly imported funcs/classes/enums/globals from external modules
Try %autoreload 3 in an IPython session after running %load_ext autoreload
- For more information please see unit test -
- extensions/tests/test_autoreload.py : 'test_autoload_newly_added_objects'
Miscelanious
Minimum supported
History Range Glob feature
Previously, when using %history, users could specify either a range of sessions and lines, for example:
~8/1-~6/5 # see history from the first line of 8 sessions ago, # to the fifth line of 6 sessions ago.``
Or users could specify a glob pattern:
-g <pattern> # glob ALL history for the specified pattern.
However users could not specify both.
If a user did specify both a range and a glob pattern, then the glob pattern would be used (globbing all history) and the range would be ignored.
---
With this enhancement, if a user specifies both a range and a glob pattern, then the glob pattern will be applied to the specified range of history.
Don't start a multi line cell with sunken parenthesis
From now on IPython will not ask for the next line of input when given a single line with more closing than opening brackets. For example, this means that if you (mis)type ']]' instead of '[]', a SyntaxError will show up, instead of the ...: prompt continuation.
IPython shell for ipdb interact
The ipdb interact starts an IPython shell instead of Python's built-in code.interact().
Automatic Vi prompt stripping
When pasting code into IPython, it will strip the leading prompt characters if there are any. For example, you can paste the following code into the console - it will still work, even though each line is prefixed with prompts (In, Out):
In [1]: 2 * 2 == 4 Out[1]: True In [2]: print("This still works as pasted")
Previously, this was not the case for the Vi-mode prompts:
In [1]: [ins] In [13]: 2 * 2 == 4 ...: Out[13]: True ...: File "<ipython-input-1-727bb88eaf33>", line 1 [ins] In [13]: 2 * 2 == 4 ^ SyntaxError: invalid syntax
This is now fixed, and Vi prompt prefixes - [ins] and [nav] - are skipped just as the normal In would be.
IPython shell can be started in the Vi mode using ipython --TerminalInteractiveShell.editing_mode=vi
Empty History Ranges
A number of magics that take history ranges can now be used with an empty range. These magics are:
- %save
- %load
- %pastebin
- %pycat
Using them this way will make them take the history of the current session up to the point of the magic call (such that the magic itself will not be included).
Therefore it is now possible to save the whole history to a file using simple %save <filename>, load and edit it using %load (makes for a nice usage when followed with :kbd:`F2`), send it to dpaste.org using %pastebin, or view the whole thing syntax-highlighted with a single %pycat.
Traceback improvements
UPDATE THIS IN INPUT.
Previously, error tracebacks for errors happening in code cells were showing a hash, the one used for compiling the Python AST:
In [1]: def foo(): ...: return 3 / 0 ...: In [2]: foo() --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) <ipython-input-2-c19b6d9633cf> in <module> ----> 1 foo() <ipython-input-1-1595a74c32d5> in foo() 1 def foo(): ----> 2 return 3 / 0 3 ZeroDivisionError: division by zero
The error traceback is now correctly formatted, showing the cell number in which the error happened:
In [1]: def foo(): ...: return 3 / 0 ...: In [2]: foo() --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) In [2], in <module> ----> 1 foo() In [1], in foo() 1 def foo(): ----> 2 return 3 / 0 ZeroDivisionError: division by zero
Remove Deprecated Stuff
We no longer need to add extensions to the PYTHONPATH because that is being handled by load_extension.
We are also removing Cythonmagic, sympyprinting and rmagic as they are now in other packages and no longer need to be inside IPython.
As a reminder, IPython master has diverged from the 7.x branch, thus master may have more feature and API changes.