##// END OF EJS Templates
typo
Matthias Bussonnier -
Show More
@@ -1,428 +1,428 b''
1 1 ============
2 2 8.x Series
3 3 ============
4 4
5 5 IPython 8.0
6 6 -----------
7 7
8 8 IPython 8.0 is still in alpha/beta stage. Please help us improve those release notes
9 9 by sending PRs that modify docs/source/whatsnew/version8.rst
10 10
11 11 IPython 8.0 is bringing a large number of new features and improvements to both the
12 12 user of the terminal and of the kernel via Jupyter. The removal of compatibility
13 13 with older version of Python is also the opportunity to do a couple of
14 14 performance improvement in particular with respect to startup time.
15 15 The 8.x branch started diverging from its predecessor around IPython 7.12
16 16 (January 2020).
17 17
18 18 This release contains 250+ Pull Requests, in addition to many of the features
19 19 and backports that have made it to the 7.x branch. All PRs that went into this
20 20 released are properly tagged with the 8.0 milestone if you wish to have a more
21 21 in depth look at the changes.
22 22
23 23 Please fell free to send pull-requests to updates those notes after release,
24 24 I have likely forgotten a few things reviewing 250+ PRs.
25 25
26 26 Dependencies changes/downstream packaging
27 27 -----------------------------------------
28 28
29 29 Note that most of our building step have been changes to be (mostly) declarative
30 30 and follow PEP 517, we are trying to completely remove ``setup.py`` (:ghpull:`13238`) and are
31 31 looking for help to do so.
32 32
33 33 - Minimum supported ``traitlets`` version if now 5+
34 34 - we now require ``stack_data``
35 35 - Minimal Python is now 3.8
36 36 - ``nose`` is not a testing requirement anymore
37 37 - ``pytest`` replaces nose.
38 38 - ``iptest``/``iptest3`` cli entrypoints do not exists anymore.
39 39 - minimum officially support ``numpy`` version has been bumped, but this should
40 40 not have much effect on packaging.
41 41
42 42
43 43 Deprecation and removal
44 44 -----------------------
45 45
46 46 We removed almost all features, arguments, functions, and modules that were
47 47 marked as deprecated between IPython 1.0 and 5.0. As reminder 5.0 was released
48 48 in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in may 2020.
49 49 The few remaining deprecated features we left have better deprecation warnings
50 50 or have been turned into explicit errors for better error messages.
51 51
52 52 I will use this occasion to add the following requests to anyone emitting a
53 53 deprecation warning:
54 54
55 55 - Please at at least ``stacklevel=2`` so that the warning is emitted into the
56 56 caller context, and not the callee one.
57 57 - Please add **since which version** something is deprecated.
58 58
59 59 As a side note it is much easier to deal with conditional comparing to versions
60 60 numbers than ``try/except`` when a functionality change with version.
61 61
62 62 I won't list all the removed features here, but modules like ``IPython.kernel``,
63 63 which was just a shim module around ``ipykernel`` for the past 8 years have been
64 64 remove, and so many other similar things that pre-date the name **Jupyter**
65 65 itself.
66 66
67 67 We no longer need to add ``IPyhton.extensions`` to the PYTHONPATH because that is being
68 68 handled by ``load_extension``.
69 69
70 70 We are also removing ``Cythonmagic``, ``sympyprinting`` and ``rmagic`` as they are now in
71 71 other packages and no longer need to be inside IPython.
72 72
73 73
74 74 Documentation
75 75 -------------
76 76
77 77 Majority of our docstrings have now been reformatted and automatically fixed by
78 78 the experimental `VΓ©lin <https://pypi.org/project/velin/>`_ project, to conform
79 79 to numpydoc.
80 80
81 81 Type annotations
82 82 ----------------
83 83
84 84 While IPython itself is highly dynamic and can't be completely typed, many of
85 85 the function now have type annotation, and part of the codebase and now checked
86 86 by mypy.
87 87
88 88
89 89 Featured changes
90 90 ----------------
91 91
92 92 Here is a features list of changes in IPython 8.0. This is of course non-exhaustive.
93 93 Please note as well that many features have been added in the 7.x branch as well
94 94 (and hence why you want to read the 7.x what's new notes), in particular
95 95 features contributed by QuantStack (with respect to debugger protocol, and Xeus
96 96 Python), as well as many debugger features that I was please to implement as
97 97 part of my work at QuanSight and Sponsored by DE Shaw.
98 98
99 99 Better Tracebacks
100 100 ~~~~~~~~~~~~~~~~~
101 101
102 102 The first on is the integration of the ``stack_data`` package;
103 103 which provide smarter informations in traceback; in particular it will highlight
104 104 the AST node where an error occurs which can help to quickly narrow down errors.
105 105
106 106 For example in the following snippet::
107 107
108 108 def foo(i):
109 109 x = [[[0]]]
110 110 return x[0][i][0]
111 111
112 112
113 113 def bar():
114 114 return foo(0) + foo(
115 115 1
116 116 ) + foo(2)
117 117
118 118
119 119 Calling ``bar()`` would raise an ``IndexError`` on the return line of ``foo``,
120 120 IPython 8.0 is capable of telling you, where the index error occurs::
121 121
122 122
123 123 IndexError
124 124 Input In [2], in <module>
125 125 ----> 1 bar()
126 126 ^^^^^
127 127
128 128 Input In [1], in bar()
129 129 6 def bar():
130 130 ----> 7 return foo(0) + foo(
131 131 ^^^^
132 132 8 1
133 133 ^^^^^^^^
134 134 9 ) + foo(2)
135 135 ^^^^
136 136
137 137 Input In [1], in foo(i)
138 138 1 def foo(i):
139 139 2 x = [[[0]]]
140 140 ----> 3 return x[0][i][0]
141 141 ^^^^^^^
142 142
143 143 Corresponding location marked here with ``^`` will show up highlighted in
144 144 terminal and notebooks.
145 145
146 146
147 147 Autosuggestons
148 148 ~~~~~~~~~~~~~~
149 149
150 150 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>`__.
151 151
152 152 `Ptpython <https://github.com/prompt-toolkit/ptpython#ptpython>`__ allows users to enable this feature in
153 153 `ptpython/config.py <https://github.com/prompt-toolkit/ptpython/blob/master/examples/ptpython_config/config.py#L90>`__.
154 154
155 155 This feature allows users to accept autosuggestions with ctrl e, ctrl f,
156 156 or right arrow as described below.
157 157
158 158 1. Start ipython
159 159
160 160 .. image:: ../_images/8.0/auto_suggest_1_prompt_no_text.png
161 161
162 162 2. Run ``print("hello")``
163 163
164 164 .. image:: ../_images/8.0/auto_suggest_2_print_hello_suggest.png
165 165
166 166 3. start typing ``print`` again to see the autosuggestion
167 167
168 168 .. image:: ../_images/8.0/auto_suggest_3_print_hello_suggest.png
169 169
170 170 4. Press ``ctrl-f``, or ``ctrl-e``, or ``right-arrow`` to accept the suggestion
171 171
172 172 .. image:: ../_images/8.0/auto_suggest_4_print_hello.png
173 173
174 174 You can also complete word by word:
175 175
176 176 1. Run ``def say_hello(): print("hello")``
177 177
178 178 .. image:: ../_images/8.0/auto_suggest_second_prompt.png
179 179
180 180 2. Start typing the first letter if ``def`` to see the autosuggestion
181 181
182 182 .. image:: ../_images/8.0/auto_suggest_d_phantom.png
183 183
184 184 3. Press ``alt-f`` (or ``escape`` followed by ``f``), to accept the first word of the suggestion
185 185
186 186 .. image:: ../_images/8.0/auto_suggest_def_phantom.png
187 187
188 188 Importantly, this feature does not interfere with tab completion:
189 189
190 190 1. After running ``def say_hello(): print("hello")``, press d
191 191
192 192 .. image:: ../_images/8.0/auto_suggest_d_phantom.png
193 193
194 194 2. Press Tab to start tab completion
195 195
196 196 .. image:: ../_images/8.0/auto_suggest_d_completions.png
197 197
198 198 3A. Press Tab again to select the first option
199 199
200 200 .. image:: ../_images/8.0/auto_suggest_def_completions.png
201 201
202 202 3B. Press ``alt f`` (``escape``, ``f``) to accept to accept the first word of the suggestion
203 203
204 204 .. image:: ../_images/8.0/auto_suggest_def_phantom.png
205 205
206 206 3C. Press ``ctrl-f`` or ``ctrl-e`` to accept the entire suggestion
207 207
208 208 .. image:: ../_images/8.0/auto_suggest_match_parens.png
209 209
210 210
211 211 Currently, autosuggestions are only shown in the emacs or vi insert editing modes:
212 212
213 213 - The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode.
214 214 - 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/>`__.
215 215
216 216
217 217 Show pinfo information in ipdb using "?" and "??"
218 218 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
219 219
220 220 In IPDB, it is now possible to show the information about an object using "?"
221 221 and "??", in much the same way it can be done when using the IPython prompt::
222 222
223 223 ipdb> partial?
224 224 Init signature: partial(self, /, *args, **kwargs)
225 225 Docstring:
226 226 partial(func, *args, **keywords) - new function with partial application
227 227 of the given arguments and keywords.
228 228 File: ~/.pyenv/versions/3.8.6/lib/python3.8/functools.py
229 229 Type: type
230 230 Subclasses:
231 231
232 232 Previously, ``pinfo`` or ``pinfo2`` command had to be used for this purpose.
233 233
234 234
235 235 Autoreload 3 feature
236 236 ~~~~~~~~~~~~~~~~~~~~
237 237
238 238 Example: When an IPython session is ran with the 'autoreload' extension loaded,
239 239 you will now have the option '3' to select which means the following:
240 240
241 241 1. replicate all functionality from option 2
242 242 2. autoload all new funcs/classes/enums/globals from the module when they are added
243 243 3. autoload all newly imported funcs/classes/enums/globals from external modules
244 244
245 245 Try ``%autoreload 3`` in an IPython session after running ``%load_ext autoreload``
246 246
247 247 For more information please see the following unit test : ``extensions/tests/test_autoreload.py:test_autoload_newly_added_objects``
248 248
249 249
250 250
251 251
252 252 History Range Glob feature
253 253 ~~~~~~~~~~~~~~~~~~~~~~~~~~
254 254
255 255 Previously, when using ``%history``, users could specify either
256 256 a range of sessions and lines, for example:
257 257
258 258 .. code-block:: python
259 259
260 260 ~8/1-~6/5 # see history from the first line of 8 sessions ago,
261 261 # to the fifth line of 6 sessions ago.``
262 262
263 263 Or users could specify a glob pattern:
264 264
265 265 .. code-block:: python
266 266
267 267 -g <pattern> # glob ALL history for the specified pattern.
268 268
269 269 However users could *not* specify both.
270 270
271 271 If a user *did* specify both a range and a glob pattern,
272 272 then the glob pattern would be used (globbing *all* history) *and the range would be ignored*.
273 273
274 274 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.
275 275
276 276 Don't start a multi line cell with sunken parenthesis
277 277 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278 278
279 279 From now on IPython will not ask for the next line of input when given a single
280 280 line with more closing than opening brackets. For example, this means that if
281 281 you (mis)type ``]]`` instead of ``[]``, a ``SyntaxError`` will show up, instead of
282 282 the ``...:`` prompt continuation.
283 283
284 284 IPython shell for ipdb interact
285 285 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286 286
287 287 The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``.
288 288
289 289 Automatic Vi prompt stripping
290 290 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291 291
292 292 When pasting code into IPython, it will strip the leading prompt characters if
293 293 there are any. For example, you can paste the following code into the console -
294 294 it will still work, even though each line is prefixed with prompts (`In`,
295 295 `Out`)::
296 296
297 297 In [1]: 2 * 2 == 4
298 298 Out[1]: True
299 299
300 300 In [2]: print("This still works as pasted")
301 301
302 302
303 303 Previously, this was not the case for the Vi-mode prompts::
304 304
305 305 In [1]: [ins] In [13]: 2 * 2 == 4
306 306 ...: Out[13]: True
307 307 ...:
308 308 File "<ipython-input-1-727bb88eaf33>", line 1
309 309 [ins] In [13]: 2 * 2 == 4
310 310 ^
311 311 SyntaxError: invalid syntax
312 312
313 313 This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are
314 314 skipped just as the normal ``In`` would be.
315 315
316 316 IPython shell can be started in the Vi mode using ``ipython --TerminalInteractiveShell.editing_mode=vi``,
317 317 You should be able to change mode dynamically with ``%config TerminalInteractiveShell.editing_mode='vi'``
318 318
319 319 Empty History Ranges
320 320 ~~~~~~~~~~~~~~~~~~~~
321 321
322 322 A number of magics that take history ranges can now be used with an empty
323 323 range. These magics are:
324 324
325 325 * ``%save``
326 326 * ``%load``
327 327 * ``%pastebin``
328 328 * ``%pycat``
329 329
330 330 Using them this way will make them take the history of the current session up
331 331 to the point of the magic call (such that the magic itself will not be
332 332 included).
333 333
334 334 Therefore it is now possible to save the whole history to a file using simple
335 335 ``%save <filename>``, load and edit it using ``%load`` (makes for a nice usage
336 336 when followed with :kbd:`F2`), send it to dpaste.org using ``%pastebin``, or
337 337 view the whole thing syntax-highlighted with a single ``%pycat``.
338 338
339 339 Traceback improvements
340 340 ~~~~~~~~~~~~~~~~~~~~~~
341 341
342 342
343 343 Previously, error tracebacks for errors happening in code cells were showing a hash, the one used for compiling the Python AST::
344 344
345 345 In [1]: def foo():
346 346 ...: return 3 / 0
347 347 ...:
348 348
349 349 In [2]: foo()
350 350 ---------------------------------------------------------------------------
351 351 ZeroDivisionError Traceback (most recent call last)
352 352 <ipython-input-2-c19b6d9633cf> in <module>
353 353 ----> 1 foo()
354 354
355 355 <ipython-input-1-1595a74c32d5> in foo()
356 356 1 def foo():
357 357 ----> 2 return 3 / 0
358 358 3
359 359
360 360 ZeroDivisionError: division by zero
361 361
362 362 The error traceback is now correctly formatted, showing the cell number in which the error happened::
363 363
364 364 In [1]: def foo():
365 365 ...: return 3 / 0
366 366 ...:
367 367
368 368 Input In [2]: foo()
369 369 ---------------------------------------------------------------------------
370 370 ZeroDivisionError Traceback (most recent call last)
371 371 input In [2], in <module>
372 372 ----> 1 foo()
373 373
374 374 Input In [1], in foo()
375 375 1 def foo():
376 376 ----> 2 return 3 / 0
377 377
378 378 ZeroDivisionError: division by zero
379 379
380 380 Miscellaneous
381 381 ~~~~~~~~~~~~~
382 382
383 383 - ``~`` is now expanded when part of a path in most magics :ghpull:`13385`
384 384 - ``%/%%timeit`` magic now adds comma every thousands to make reading long number easier :ghpull:`13379`
385 385 - ``"info"`` messages can now be customised to hide some fields :ghpull:`13343`
386 386 - ``collections.UserList`` now pretty-prints :ghpull:`13320`
387 387 - The debugger now have a persistent history, which should make it less
388 388 annoying to retype commands :ghpull:`13246`
389 389 - ``!pip`` ``!conda`` ``!cd`` or ``!ls`` are likely doing the wrong thing, we
390 390 now warn users if they use it. :ghpull:`12954`
391 391 - make ``%precision`` work for ``numpy.float64`` type :ghpull:`12902`
392 392
393 393
394 394
395 395
396 396 Numfocus Small Developer Grant
397 397 ------------------------------
398 398
399 399 To prepare for Python 3.10 we have also started working on removing reliance and
400 400 any dependency that is not Python 3.10 compatible; that include migrating our
401 401 test suite to pytest, and starting to remove nose. This also mean that the
402 402 ``iptest`` command is now gone, and all testing is via pytest.
403 403
404 404 This was in large part thanks to the NumFOCUS Small Developer grant, which enabled us to
405 allocate \$4000 to hire `Nikita Kniazev (@Kojoley) <https://github.com/Kojoley>`,
405 allocate \$4000 to hire `Nikita Kniazev (@Kojoley) <https://github.com/Kojoley>`_,
406 406 who did a fantastic job at updating our code base, migrating to pytest, pushing
407 407 our coverage, and fixing a large number of bugs. I highly recommend contacting
408 408 them if you need help with C++ and Python projects
409 409
410 410 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+>`__
411 411
412 412 Removing support for Older Python
413 413 ---------------------------------
414 414
415 415
416 416 We are also removing support for Python up to 3.7 allowing internal code to use more
417 417 efficient ``pathlib``, and make better use of type annotations.
418 418
419 419 .. image:: ../_images/8.0/pathlib_pathlib_everywhere.jpg
420 420 :alt: "Meme image of Toy Story with Woody and Buzz, with the text 'pathlib, pathlib everywhere'"
421 421
422 422
423 423 We have about 34 PRs only to update some logic tu update some function from managing strings to
424 424 using Pathlib.
425 425
426 426 The completer has also seen significant updates and make use of newer Jedi API
427 427 offering faster and more reliable tab completion.
428 428
General Comments 0
You need to be logged in to leave comments. Login now