|
@@
-1,220
+1,361
b''
|
|
1
|
1
|
=====================
|
|
2
|
2
|
Development version
|
|
3
|
3
|
=====================
|
|
4
|
4
|
|
|
5
|
5
|
This document describes in-flight development work.
|
|
6
|
6
|
|
|
7
|
7
|
.. warning::
|
|
8
|
8
|
|
|
9
|
9
|
Please do not edit this file by hand (doing so will likely cause merge
|
|
10
|
10
|
conflicts for other Pull Requests). Instead, create a new file in the
|
|
11
|
11
|
`docs/source/whatsnew/pr` folder
|
|
12
|
12
|
|
|
13
|
13
|
|
|
14
|
14
|
Released .... ...., 2019
|
|
15
|
15
|
|
|
16
|
16
|
|
|
17
|
17
|
Need to be updated:
|
|
18
|
18
|
|
|
19
|
19
|
.. toctree::
|
|
20
|
20
|
:maxdepth: 2
|
|
21
|
21
|
:glob:
|
|
22
|
22
|
|
|
23
|
23
|
pr/*
|
|
24
|
24
|
|
|
25
|
25
|
IPython 8.0 is bringing a large number of new features and improvements to both the
|
|
26
|
26
|
user of the terminal and of the kernel via Jupyter. The removal of compatibility
|
|
27
|
27
|
with older version of Python is also the opportunity to do a couple of
|
|
28
|
28
|
performance improvement in particular with respect to startup time.
|
|
29
|
29
|
|
|
30
|
30
|
This release contains 250+ Pull requests, in addition to many of the features
|
|
31
|
31
|
and backports that have made it to the 7.x branch.
|
|
32
|
32
|
|
|
33
|
33
|
We removed almost all features, arguments, functions, and modules that were
|
|
34
|
34
|
marked as deprecated between IPython 1.0 and 5.0 and before. As reminder 5.0 was
|
|
35
|
35
|
released in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in
|
|
36
|
36
|
may 2020. The few remaining deprecated features have better deprecation warnings
|
|
37
|
37
|
or errors.
|
|
38
|
38
|
|
|
39
|
39
|
There are many change in IPython 8.0 will will try to describe subsequently,
|
|
40
|
40
|
|
|
41
|
41
|
|
|
42
|
42
|
The first on is the integration of the ``stack_data`` package;
|
|
43
|
43
|
which provide smarter information in traceback; in particular it will highlight
|
|
44
|
44
|
the AST node where an error occurs which can help to quickly narrow down errors.
|
|
45
|
45
|
|
|
46
|
46
|
For example in the following snippet::
|
|
47
|
47
|
|
|
48
|
48
|
def foo(i):
|
|
49
|
49
|
x = [[[0]]]
|
|
50
|
50
|
return x[0][i][0]
|
|
51
|
51
|
|
|
52
|
52
|
|
|
53
|
53
|
def bar():
|
|
54
|
54
|
return foo(0) + foo(
|
|
55
|
55
|
1
|
|
56
|
56
|
) + foo(2)
|
|
57
|
57
|
|
|
58
|
58
|
|
|
59
|
59
|
Calling ``bar()`` would raise an ``IndexError`` on the return line of ``foo``,
|
|
60
|
60
|
IPython 8.0 is capable of telling you, where the index error occurs::
|
|
61
|
61
|
|
|
62
|
62
|
return x[0][i][0]
|
|
63
|
63
|
^
|
|
64
|
64
|
|
|
65
|
65
|
|
|
66
|
66
|
Numfocus Small Developer Grant
|
|
67
|
67
|
------------------------------
|
|
68
|
68
|
|
|
69
|
69
|
To prepare for Python 3.10 we have also started working on removing reliance and
|
|
70
|
70
|
any dependency that is not Python 3.10 compatible; that include migrating our
|
|
71
|
71
|
test suite to pytest, and starting to remove nose. This also mean that the
|
|
72
|
72
|
``iptest`` command is now gone, and all testing is via pytest.
|
|
73
|
73
|
|
|
74
|
74
|
This was in bog part thanks the NumFOCUS Small Developer grant, we were able to
|
|
75
|
75
|
allocate 4000 to hire `Nikita Kniazev @Kojoley <https://github.com/Kojoley>`__
|
|
76
|
76
|
who did a fantastic job at updating our code base, migrating to pytest, pushing
|
|
77
|
77
|
our coverage, and fixing a large number of bugs. I highly recommend contacting
|
|
78
|
78
|
them if you need help with C++ and Python projects
|
|
79
|
79
|
|
|
80
|
80
|
You can find all relevant issues and PRs with the SDG 2021 tag:
|
|
81
|
81
|
|
|
82
|
82
|
https://github.com/ipython/ipython/issues?q=label%3A%22Numfocus+SDG+2021%22+
|
|
83
|
83
|
|
|
84
|
84
|
Removing support for Older Python
|
|
85
|
85
|
---------------------------------
|
|
86
|
86
|
|
|
87
|
87
|
|
|
88
|
88
|
We are also removing support for Python up to 3.7 allowing internal code to use more
|
|
89
|
89
|
efficient ``pathlib``, and make better use of type annotations.
|
|
90
|
90
|
|
|
91
|
91
|
IMAGE : Pathlib, pathlib everywhere.
|
|
92
|
92
|
|
|
93
|
93
|
The completer has also seen significant updates and make use of newer Jedi API
|
|
94
|
94
|
offering faster and more reliable tab completion.
|
|
95
|
95
|
|
|
96
|
96
|
For the terminal users this also enable the auto-suggestion feature, described
|
|
97
|
97
|
below, which show "ghost text" ahead of your cursor you can accept without
|
|
98
|
98
|
having to press the tab key or ask the completer to suggest completions.
|
|
99
|
99
|
|
|
100
|
100
|
|
|
101
|
101
|
Autosuggestion is a very useful feature available in `fish <https://fishshell.com/>`__, `zsh <https://en.wikipedia.org/wiki/Z_shell>`__, and `prompt-toolkit <https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#auto-suggestion>`__.
|
|
102
|
102
|
|
|
103
|
103
|
`Ptpython <https://github.com/prompt-toolkit/ptpython#ptpython>`__ allows users to enable this feature in
|
|
104
|
104
|
`ptpython/config.py <https://github.com/prompt-toolkit/ptpython/blob/master/examples/ptpython_config/config.py#L90>`__.
|
|
105
|
105
|
|
|
106
|
106
|
This feature allows users to accept autosuggestions with ctrl e, ctrl f,
|
|
107
|
107
|
or right arrow as described below.
|
|
108
|
108
|
|
|
109
|
109
|
1. Start ipython
|
|
110
|
110
|
|
|
111
|
111
|
.. image:: ../_images/auto_suggest_prompt_no_text.png
|
|
112
|
112
|
|
|
113
|
113
|
2. Run ``print("hello")``
|
|
114
|
114
|
|
|
115
|
115
|
.. image:: ../_images/auto_suggest_print_hello_suggest.png
|
|
116
|
116
|
|
|
117
|
117
|
3. Press p to see the autosuggestion
|
|
118
|
118
|
|
|
119
|
119
|
.. image:: ../_images/auto_suggest_print_hello_suggest.png
|
|
120
|
120
|
|
|
121
|
121
|
4. Press ctrl f, or ctrl e, or right arrow to accept the suggestion
|
|
122
|
122
|
|
|
123
|
123
|
.. image:: ../_images/auto_suggest_print_hello.png
|
|
124
|
124
|
|
|
125
|
125
|
You can also complete word by word:
|
|
126
|
126
|
|
|
127
|
127
|
1. Run ``def say_hello(): print("hello")``
|
|
128
|
128
|
|
|
129
|
129
|
.. image:: ../_images/auto_suggest_second_prompt.png
|
|
130
|
130
|
|
|
131
|
131
|
2. Press d to see the autosuggestion
|
|
132
|
132
|
|
|
133
|
133
|
.. image:: ../_images/audo_suggest_d_phantom.png
|
|
134
|
134
|
|
|
135
|
135
|
3. Press alt f to accept the first word of the suggestion
|
|
136
|
136
|
|
|
137
|
137
|
.. image:: ../_images/auto_suggest_def_phantom.png
|
|
138
|
138
|
|
|
139
|
139
|
Importantly, this feature does not interfere with tab completion:
|
|
140
|
140
|
|
|
141
|
141
|
1. After running ``def say_hello(): print("hello")``, press d
|
|
142
|
142
|
|
|
143
|
143
|
.. image:: ../_images/audo_suggest_d_phantom.png
|
|
144
|
144
|
|
|
145
|
145
|
2. Press Tab to start tab completion
|
|
146
|
146
|
|
|
147
|
147
|
.. image:: ../_images/auto_suggest_d_completions.png
|
|
148
|
148
|
|
|
149
|
149
|
3A. Press Tab again to select the first option
|
|
150
|
150
|
|
|
151
|
151
|
.. image:: ../_images/auto_suggest_def_completions.png
|
|
152
|
152
|
|
|
153
|
153
|
3B. Press alt f to accept to accept the first word of the suggestion
|
|
154
|
154
|
|
|
155
|
155
|
.. image:: ../_images/auto_suggest_def_phantom.png
|
|
156
|
156
|
|
|
157
|
157
|
3C. Press ctrl f or ctrl e to accept the entire suggestion
|
|
158
|
158
|
|
|
159
|
159
|
.. image:: ../_images/auto_suggest_match_parens.png
|
|
160
|
160
|
|
|
161
|
161
|
To install a version of ipython with autosuggestions enabled, run:
|
|
162
|
162
|
|
|
163
|
163
|
``pip install git+https://github.com/mskar/ipython@auto_suggest``
|
|
164
|
164
|
|
|
165
|
165
|
Currently, autosuggestions are only shown in the emacs or vi insert editing modes:
|
|
166
|
166
|
|
|
167
|
167
|
- The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode.
|
|
168
|
168
|
- To use these shortcuts in vi insert mode, you will have to create `custom keybindings in your config.py <https://github.com/mskar/setup/commit/2892fcee46f9f80ef7788f0749edc99daccc52f4/>`__.
|
|
169
|
169
|
|
|
170
|
170
|
|
|
171
|
171
|
Show pinfo information in ipdb using "?" and "??"
|
|
172
|
172
|
-------------------------------------------------
|
|
173
|
173
|
|
|
174
|
174
|
In IPDB, it is now possible to show the information about an object using "?"
|
|
175
|
175
|
and "??", in much the same way it can be done when using the IPython prompt::
|
|
176
|
176
|
|
|
177
|
177
|
ipdb> partial?
|
|
178
|
178
|
Init signature: partial(self, /, *args, **kwargs)
|
|
179
|
179
|
Docstring:
|
|
180
|
180
|
partial(func, *args, **keywords) - new function with partial application
|
|
181
|
181
|
of the given arguments and keywords.
|
|
182
|
182
|
File: ~/.pyenv/versions/3.8.6/lib/python3.8/functools.py
|
|
183
|
183
|
Type: type
|
|
184
|
184
|
Subclasses:
|
|
185
|
185
|
|
|
186
|
186
|
Previously, "pinfo" or "pinfo2" command had to be used for this purpose.
|
|
187
|
187
|
|
|
188
|
188
|
|
|
189
|
189
|
Autoreload 3 feature
|
|
190
|
190
|
====================
|
|
191
|
191
|
|
|
192
|
192
|
Example: When an IPython session is ran with the 'autoreload' extension loaded,
|
|
193
|
193
|
you will now have the option '3' to select which means the following:
|
|
194
|
194
|
|
|
195
|
195
|
1. replicate all functionality from option 2
|
|
196
|
196
|
2. autoload all new funcs/classes/enums/globals from the module when they're added
|
|
197
|
197
|
3. autoload all newly imported funcs/classes/enums/globals from external modules
|
|
198
|
198
|
|
|
199
|
199
|
Try ``%autoreload 3`` in an IPython session after running ``%load_ext autoreload``
|
|
200
|
200
|
|
|
201
|
201
|
For more information please see unit test -
|
|
202
|
202
|
extensions/tests/test_autoreload.py : 'test_autoload_newly_added_objects'
|
|
203
|
203
|
|
|
204
|
204
|
|
|
205
|
205
|
Miscelanious
|
|
206
|
206
|
------------
|
|
207
|
207
|
|
|
208
|
208
|
Minimum supported
|
|
209
|
209
|
|
|
210
|
|
=======
|
|
|
210
|
|
|
|
211
|
History Range Glob feature
|
|
|
212
|
==========================
|
|
|
213
|
|
|
|
214
|
Previously, when using ``%history``, users could specify either
|
|
|
215
|
a range of sessions and lines, for example:
|
|
|
216
|
|
|
|
217
|
.. code-block:: python
|
|
|
218
|
|
|
|
219
|
~8/1-~6/5 # see history from the first line of 8 sessions ago,
|
|
|
220
|
# to the fifth line of 6 sessions ago.``
|
|
|
221
|
|
|
|
222
|
Or users could specify a glob pattern:
|
|
|
223
|
|
|
|
224
|
.. code-block:: python
|
|
|
225
|
|
|
|
226
|
-g <pattern> # glob ALL history for the specified pattern.
|
|
|
227
|
|
|
|
228
|
However users could *not* specify both.
|
|
|
229
|
|
|
|
230
|
If a user *did* specify both a range and a glob pattern,
|
|
|
231
|
then the glob pattern would be used (globbing *all* history) *and the range would be ignored*.
|
|
|
232
|
|
|
|
233
|
---
|
|
|
234
|
|
|
|
235
|
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.
|
|
|
236
|
|
|
|
237
|
Don't start a multi line cell with sunken parenthesis
|
|
|
238
|
-----------------------------------------------------
|
|
|
239
|
|
|
|
240
|
From now on IPython will not ask for the next line of input when given a single
|
|
|
241
|
line with more closing than opening brackets. For example, this means that if
|
|
|
242
|
you (mis)type ']]' instead of '[]', a ``SyntaxError`` will show up, instead of
|
|
|
243
|
the ``...:`` prompt continuation.
|
|
|
244
|
|
|
|
245
|
IPython shell for ipdb interact
|
|
|
246
|
-------------------------------
|
|
|
247
|
|
|
|
248
|
The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``.
|
|
|
249
|
|
|
|
250
|
Automatic Vi prompt stripping
|
|
|
251
|
=============================
|
|
|
252
|
|
|
|
253
|
When pasting code into IPython, it will strip the leading prompt characters if
|
|
|
254
|
there are any. For example, you can paste the following code into the console -
|
|
|
255
|
it will still work, even though each line is prefixed with prompts (`In`,
|
|
|
256
|
`Out`)::
|
|
|
257
|
|
|
|
258
|
In [1]: 2 * 2 == 4
|
|
|
259
|
Out[1]: True
|
|
|
260
|
|
|
|
261
|
In [2]: print("This still works as pasted")
|
|
|
262
|
|
|
|
263
|
|
|
|
264
|
Previously, this was not the case for the Vi-mode prompts::
|
|
|
265
|
|
|
|
266
|
In [1]: [ins] In [13]: 2 * 2 == 4
|
|
|
267
|
...: Out[13]: True
|
|
|
268
|
...:
|
|
|
269
|
File "<ipython-input-1-727bb88eaf33>", line 1
|
|
|
270
|
[ins] In [13]: 2 * 2 == 4
|
|
|
271
|
^
|
|
|
272
|
SyntaxError: invalid syntax
|
|
|
273
|
|
|
|
274
|
This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are
|
|
|
275
|
skipped just as the normal ``In`` would be.
|
|
|
276
|
|
|
|
277
|
IPython shell can be started in the Vi mode using ``ipython
|
|
|
278
|
--TerminalInteractiveShell.editing_mode=vi``
|
|
|
279
|
|
|
|
280
|
Empty History Ranges
|
|
|
281
|
====================
|
|
|
282
|
|
|
|
283
|
A number of magics that take history ranges can now be used with an empty
|
|
|
284
|
range. These magics are:
|
|
|
285
|
|
|
|
286
|
* ``%save``
|
|
|
287
|
* ``%load``
|
|
|
288
|
* ``%pastebin``
|
|
|
289
|
* ``%pycat``
|
|
|
290
|
|
|
|
291
|
Using them this way will make them take the history of the current session up
|
|
|
292
|
to the point of the magic call (such that the magic itself will not be
|
|
|
293
|
included).
|
|
|
294
|
|
|
|
295
|
Therefore it is now possible to save the whole history to a file using simple
|
|
|
296
|
``%save <filename>``, load and edit it using ``%load`` (makes for a nice usage
|
|
|
297
|
when followed with :kbd:`F2`), send it to dpaste.org using ``%pastebin``, or
|
|
|
298
|
view the whole thing syntax-highlighted with a single ``%pycat``.
|
|
|
299
|
|
|
|
300
|
Traceback improvements
|
|
|
301
|
======================
|
|
|
302
|
|
|
|
303
|
|
|
|
304
|
UPDATE THIS IN INPUT.
|
|
|
305
|
|
|
|
306
|
Previously, error tracebacks for errors happening in code cells were showing a hash, the one used for compiling the Python AST::
|
|
|
307
|
|
|
|
308
|
In [1]: def foo():
|
|
|
309
|
...: return 3 / 0
|
|
|
310
|
...:
|
|
|
311
|
|
|
|
312
|
In [2]: foo()
|
|
|
313
|
---------------------------------------------------------------------------
|
|
|
314
|
ZeroDivisionError Traceback (most recent call last)
|
|
|
315
|
<ipython-input-2-c19b6d9633cf> in <module>
|
|
|
316
|
----> 1 foo()
|
|
|
317
|
|
|
|
318
|
<ipython-input-1-1595a74c32d5> in foo()
|
|
|
319
|
1 def foo():
|
|
|
320
|
----> 2 return 3 / 0
|
|
|
321
|
3
|
|
|
322
|
|
|
|
323
|
ZeroDivisionError: division by zero
|
|
|
324
|
|
|
|
325
|
The error traceback is now correctly formatted, showing the cell number in which the error happened::
|
|
|
326
|
|
|
|
327
|
In [1]: def foo():
|
|
|
328
|
...: return 3 / 0
|
|
|
329
|
...:
|
|
|
330
|
|
|
|
331
|
In [2]: foo()
|
|
|
332
|
---------------------------------------------------------------------------
|
|
|
333
|
ZeroDivisionError Traceback (most recent call last)
|
|
|
334
|
In [2], in <module>
|
|
|
335
|
----> 1 foo()
|
|
|
336
|
|
|
|
337
|
In [1], in foo()
|
|
|
338
|
1 def foo():
|
|
|
339
|
----> 2 return 3 / 0
|
|
|
340
|
|
|
|
341
|
ZeroDivisionError: division by zero
|
|
|
342
|
|
|
|
343
|
Remove Deprecated Stuff
|
|
|
344
|
=======================
|
|
|
345
|
|
|
|
346
|
|
|
|
347
|
We no longer need to add `extensions` to the PYTHONPATH because that is being
|
|
|
348
|
handled by `load_extension`.
|
|
|
349
|
|
|
|
350
|
We are also removing Cythonmagic, sympyprinting and rmagic as they are now in
|
|
|
351
|
other packages and no longer need to be inside IPython.
|
|
211
|
352
|
|
|
212
|
353
|
.. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
|
|
213
|
354
|
|
|
214
|
355
|
As a reminder, IPython master has diverged from the 7.x branch, thus master may
|
|
215
|
356
|
have more feature and API changes.
|
|
216
|
357
|
|
|
217
|
358
|
Backwards incompatible changes
|
|
218
|
359
|
------------------------------
|
|
219
|
360
|
|
|
220
|
361
|
.. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT.
|