##// END OF EJS Templates
ENH: add webp support to IPython.display.Image and complete identification of JPEG,PNG,GIF,WEBP image types by initial bytes (#14526)...
M Bussonnier -
r28924:d7d58a36 merge
parent child Browse files
Show More
@@ -1,1294 +1,1370
1 1 # -*- coding: utf-8 -*-
2 2 """Top-level display functions for displaying object in different formats."""
3 3
4 4 # Copyright (c) IPython Development Team.
5 5 # Distributed under the terms of the Modified BSD License.
6 6
7 7
8 8 from binascii import b2a_base64, hexlify
9 9 import html
10 10 import json
11 11 import mimetypes
12 12 import os
13 13 import struct
14 14 import warnings
15 15 from copy import deepcopy
16 16 from os.path import splitext
17 17 from pathlib import Path, PurePath
18 18
19 19 from IPython.utils.py3compat import cast_unicode
20 20 from IPython.testing.skipdoctest import skip_doctest
21 21 from . import display_functions
22 22
23 23
24 __all__ = ['display_pretty', 'display_html', 'display_markdown',
25 'display_svg', 'display_png', 'display_jpeg', 'display_latex', 'display_json',
26 'display_javascript', 'display_pdf', 'DisplayObject', 'TextDisplayObject',
27 'Pretty', 'HTML', 'Markdown', 'Math', 'Latex', 'SVG', 'ProgressBar', 'JSON',
28 'GeoJSON', 'Javascript', 'Image', 'set_matplotlib_formats',
29 'set_matplotlib_close',
30 'Video']
24 __all__ = [
25 "display_pretty",
26 "display_html",
27 "display_markdown",
28 "display_svg",
29 "display_png",
30 "display_jpeg",
31 "display_webp",
32 "display_latex",
33 "display_json",
34 "display_javascript",
35 "display_pdf",
36 "DisplayObject",
37 "TextDisplayObject",
38 "Pretty",
39 "HTML",
40 "Markdown",
41 "Math",
42 "Latex",
43 "SVG",
44 "ProgressBar",
45 "JSON",
46 "GeoJSON",
47 "Javascript",
48 "Image",
49 "set_matplotlib_formats",
50 "set_matplotlib_close",
51 "Video",
52 ]
31 53
32 54 _deprecated_names = ["display", "clear_output", "publish_display_data", "update_display", "DisplayHandle"]
33 55
34 56 __all__ = __all__ + _deprecated_names
35 57
36 58
37 59 # ----- warn to import from IPython.display -----
38 60
39 61 from warnings import warn
40 62
41 63
42 64 def __getattr__(name):
43 65 if name in _deprecated_names:
44 66 warn(
45 67 f"Importing {name} from IPython.core.display is deprecated since IPython 7.14, please import from IPython.display",
46 68 DeprecationWarning,
47 69 stacklevel=2,
48 70 )
49 71 return getattr(display_functions, name)
50 72
51 73 if name in globals().keys():
52 74 return globals()[name]
53 75 else:
54 76 raise AttributeError(f"module {__name__} has no attribute {name}")
55 77
56 78
57 79 #-----------------------------------------------------------------------------
58 80 # utility functions
59 81 #-----------------------------------------------------------------------------
60 82
61 83 def _safe_exists(path):
62 84 """Check path, but don't let exceptions raise"""
63 85 try:
64 86 return os.path.exists(path)
65 87 except Exception:
66 88 return False
67 89
68 90
69 91 def _display_mimetype(mimetype, objs, raw=False, metadata=None):
70 92 """internal implementation of all display_foo methods
71 93
72 94 Parameters
73 95 ----------
74 96 mimetype : str
75 97 The mimetype to be published (e.g. 'image/png')
76 98 *objs : object
77 99 The Python objects to display, or if raw=True raw text data to
78 100 display.
79 101 raw : bool
80 102 Are the data objects raw data or Python objects that need to be
81 103 formatted before display? [default: False]
82 104 metadata : dict (optional)
83 105 Metadata to be associated with the specific mimetype output.
84 106 """
85 107 if metadata:
86 108 metadata = {mimetype: metadata}
87 109 if raw:
88 110 # turn list of pngdata into list of { 'image/png': pngdata }
89 111 objs = [ {mimetype: obj} for obj in objs ]
90 112 display_functions.display(*objs, raw=raw, metadata=metadata, include=[mimetype])
91 113
92 114 #-----------------------------------------------------------------------------
93 115 # Main functions
94 116 #-----------------------------------------------------------------------------
95 117
96 118
97 119 def display_pretty(*objs, **kwargs):
98 120 """Display the pretty (default) representation of an object.
99 121
100 122 Parameters
101 123 ----------
102 124 *objs : object
103 125 The Python objects to display, or if raw=True raw text data to
104 126 display.
105 127 raw : bool
106 128 Are the data objects raw data or Python objects that need to be
107 129 formatted before display? [default: False]
108 130 metadata : dict (optional)
109 131 Metadata to be associated with the specific mimetype output.
110 132 """
111 133 _display_mimetype('text/plain', objs, **kwargs)
112 134
113 135
114 136 def display_html(*objs, **kwargs):
115 137 """Display the HTML representation of an object.
116 138
117 139 Note: If raw=False and the object does not have a HTML
118 140 representation, no HTML will be shown.
119 141
120 142 Parameters
121 143 ----------
122 144 *objs : object
123 145 The Python objects to display, or if raw=True raw HTML data to
124 146 display.
125 147 raw : bool
126 148 Are the data objects raw data or Python objects that need to be
127 149 formatted before display? [default: False]
128 150 metadata : dict (optional)
129 151 Metadata to be associated with the specific mimetype output.
130 152 """
131 153 _display_mimetype('text/html', objs, **kwargs)
132 154
133 155
134 156 def display_markdown(*objs, **kwargs):
135 157 """Displays the Markdown representation of an object.
136 158
137 159 Parameters
138 160 ----------
139 161 *objs : object
140 162 The Python objects to display, or if raw=True raw markdown data to
141 163 display.
142 164 raw : bool
143 165 Are the data objects raw data or Python objects that need to be
144 166 formatted before display? [default: False]
145 167 metadata : dict (optional)
146 168 Metadata to be associated with the specific mimetype output.
147 169 """
148 170
149 171 _display_mimetype('text/markdown', objs, **kwargs)
150 172
151 173
152 174 def display_svg(*objs, **kwargs):
153 175 """Display the SVG representation of an object.
154 176
155 177 Parameters
156 178 ----------
157 179 *objs : object
158 180 The Python objects to display, or if raw=True raw svg data to
159 181 display.
160 182 raw : bool
161 183 Are the data objects raw data or Python objects that need to be
162 184 formatted before display? [default: False]
163 185 metadata : dict (optional)
164 186 Metadata to be associated with the specific mimetype output.
165 187 """
166 188 _display_mimetype('image/svg+xml', objs, **kwargs)
167 189
168 190
169 191 def display_png(*objs, **kwargs):
170 192 """Display the PNG representation of an object.
171 193
172 194 Parameters
173 195 ----------
174 196 *objs : object
175 197 The Python objects to display, or if raw=True raw png data to
176 198 display.
177 199 raw : bool
178 200 Are the data objects raw data or Python objects that need to be
179 201 formatted before display? [default: False]
180 202 metadata : dict (optional)
181 203 Metadata to be associated with the specific mimetype output.
182 204 """
183 205 _display_mimetype('image/png', objs, **kwargs)
184 206
185 207
186 208 def display_jpeg(*objs, **kwargs):
187 209 """Display the JPEG representation of an object.
188 210
189 211 Parameters
190 212 ----------
191 213 *objs : object
192 214 The Python objects to display, or if raw=True raw JPEG data to
193 215 display.
194 216 raw : bool
195 217 Are the data objects raw data or Python objects that need to be
196 218 formatted before display? [default: False]
197 219 metadata : dict (optional)
198 220 Metadata to be associated with the specific mimetype output.
199 221 """
200 222 _display_mimetype('image/jpeg', objs, **kwargs)
201 223
202 224
225 def display_webp(*objs, **kwargs):
226 """Display the WEBP representation of an object.
227
228 Parameters
229 ----------
230 *objs : object
231 The Python objects to display, or if raw=True raw JPEG data to
232 display.
233 raw : bool
234 Are the data objects raw data or Python objects that need to be
235 formatted before display? [default: False]
236 metadata : dict (optional)
237 Metadata to be associated with the specific mimetype output.
238 """
239 _display_mimetype("image/webp", objs, **kwargs)
240
241
203 242 def display_latex(*objs, **kwargs):
204 243 """Display the LaTeX representation of an object.
205 244
206 245 Parameters
207 246 ----------
208 247 *objs : object
209 248 The Python objects to display, or if raw=True raw latex data to
210 249 display.
211 250 raw : bool
212 251 Are the data objects raw data or Python objects that need to be
213 252 formatted before display? [default: False]
214 253 metadata : dict (optional)
215 254 Metadata to be associated with the specific mimetype output.
216 255 """
217 256 _display_mimetype('text/latex', objs, **kwargs)
218 257
219 258
220 259 def display_json(*objs, **kwargs):
221 260 """Display the JSON representation of an object.
222 261
223 262 Note that not many frontends support displaying JSON.
224 263
225 264 Parameters
226 265 ----------
227 266 *objs : object
228 267 The Python objects to display, or if raw=True raw json data to
229 268 display.
230 269 raw : bool
231 270 Are the data objects raw data or Python objects that need to be
232 271 formatted before display? [default: False]
233 272 metadata : dict (optional)
234 273 Metadata to be associated with the specific mimetype output.
235 274 """
236 275 _display_mimetype('application/json', objs, **kwargs)
237 276
238 277
239 278 def display_javascript(*objs, **kwargs):
240 279 """Display the Javascript representation of an object.
241 280
242 281 Parameters
243 282 ----------
244 283 *objs : object
245 284 The Python objects to display, or if raw=True raw javascript data to
246 285 display.
247 286 raw : bool
248 287 Are the data objects raw data or Python objects that need to be
249 288 formatted before display? [default: False]
250 289 metadata : dict (optional)
251 290 Metadata to be associated with the specific mimetype output.
252 291 """
253 292 _display_mimetype('application/javascript', objs, **kwargs)
254 293
255 294
256 295 def display_pdf(*objs, **kwargs):
257 296 """Display the PDF representation of an object.
258 297
259 298 Parameters
260 299 ----------
261 300 *objs : object
262 301 The Python objects to display, or if raw=True raw javascript data to
263 302 display.
264 303 raw : bool
265 304 Are the data objects raw data or Python objects that need to be
266 305 formatted before display? [default: False]
267 306 metadata : dict (optional)
268 307 Metadata to be associated with the specific mimetype output.
269 308 """
270 309 _display_mimetype('application/pdf', objs, **kwargs)
271 310
272 311
273 312 #-----------------------------------------------------------------------------
274 313 # Smart classes
275 314 #-----------------------------------------------------------------------------
276 315
277 316
278 317 class DisplayObject(object):
279 318 """An object that wraps data to be displayed."""
280 319
281 320 _read_flags = 'r'
282 321 _show_mem_addr = False
283 322 metadata = None
284 323
285 324 def __init__(self, data=None, url=None, filename=None, metadata=None):
286 325 """Create a display object given raw data.
287 326
288 327 When this object is returned by an expression or passed to the
289 328 display function, it will result in the data being displayed
290 329 in the frontend. The MIME type of the data should match the
291 330 subclasses used, so the Png subclass should be used for 'image/png'
292 331 data. If the data is a URL, the data will first be downloaded
293 332 and then displayed.
294 333
295 334 Parameters
296 335 ----------
297 336 data : unicode, str or bytes
298 337 The raw data or a URL or file to load the data from
299 338 url : unicode
300 339 A URL to download the data from.
301 340 filename : unicode
302 341 Path to a local file to load the data from.
303 342 metadata : dict
304 343 Dict of metadata associated to be the object when displayed
305 344 """
306 345 if isinstance(data, (Path, PurePath)):
307 346 data = str(data)
308 347
309 348 if data is not None and isinstance(data, str):
310 349 if data.startswith('http') and url is None:
311 350 url = data
312 351 filename = None
313 352 data = None
314 353 elif _safe_exists(data) and filename is None:
315 354 url = None
316 355 filename = data
317 356 data = None
318 357
319 358 self.url = url
320 359 self.filename = filename
321 360 # because of @data.setter methods in
322 361 # subclasses ensure url and filename are set
323 362 # before assigning to self.data
324 363 self.data = data
325 364
326 365 if metadata is not None:
327 366 self.metadata = metadata
328 367 elif self.metadata is None:
329 368 self.metadata = {}
330 369
331 370 self.reload()
332 371 self._check_data()
333 372
334 373 def __repr__(self):
335 374 if not self._show_mem_addr:
336 375 cls = self.__class__
337 376 r = "<%s.%s object>" % (cls.__module__, cls.__name__)
338 377 else:
339 378 r = super(DisplayObject, self).__repr__()
340 379 return r
341 380
342 381 def _check_data(self):
343 382 """Override in subclasses if there's something to check."""
344 383 pass
345 384
346 385 def _data_and_metadata(self):
347 386 """shortcut for returning metadata with shape information, if defined"""
348 387 if self.metadata:
349 388 return self.data, deepcopy(self.metadata)
350 389 else:
351 390 return self.data
352 391
353 392 def reload(self):
354 393 """Reload the raw data from file or URL."""
355 394 if self.filename is not None:
356 395 encoding = None if "b" in self._read_flags else "utf-8"
357 396 with open(self.filename, self._read_flags, encoding=encoding) as f:
358 397 self.data = f.read()
359 398 elif self.url is not None:
360 399 # Deferred import
361 400 from urllib.request import urlopen
362 401 response = urlopen(self.url)
363 402 data = response.read()
364 403 # extract encoding from header, if there is one:
365 404 encoding = None
366 405 if 'content-type' in response.headers:
367 406 for sub in response.headers['content-type'].split(';'):
368 407 sub = sub.strip()
369 408 if sub.startswith('charset'):
370 409 encoding = sub.split('=')[-1].strip()
371 410 break
372 411 if 'content-encoding' in response.headers:
373 412 # TODO: do deflate?
374 413 if 'gzip' in response.headers['content-encoding']:
375 414 import gzip
376 415 from io import BytesIO
377 416
378 417 # assume utf-8 if encoding is not specified
379 418 with gzip.open(
380 419 BytesIO(data), "rt", encoding=encoding or "utf-8"
381 420 ) as fp:
382 421 encoding = None
383 422 data = fp.read()
384 423
385 424 # decode data, if an encoding was specified
386 425 # We only touch self.data once since
387 426 # subclasses such as SVG have @data.setter methods
388 427 # that transform self.data into ... well svg.
389 428 if encoding:
390 429 self.data = data.decode(encoding, 'replace')
391 430 else:
392 431 self.data = data
393 432
394 433
395 434 class TextDisplayObject(DisplayObject):
396 435 """Create a text display object given raw data.
397 436
398 437 Parameters
399 438 ----------
400 439 data : str or unicode
401 440 The raw data or a URL or file to load the data from.
402 441 url : unicode
403 442 A URL to download the data from.
404 443 filename : unicode
405 444 Path to a local file to load the data from.
406 445 metadata : dict
407 446 Dict of metadata associated to be the object when displayed
408 447 """
409 448 def _check_data(self):
410 449 if self.data is not None and not isinstance(self.data, str):
411 450 raise TypeError("%s expects text, not %r" % (self.__class__.__name__, self.data))
412 451
413 452 class Pretty(TextDisplayObject):
414 453
415 454 def _repr_pretty_(self, pp, cycle):
416 455 return pp.text(self.data)
417 456
418 457
419 458 class HTML(TextDisplayObject):
420 459
421 460 def __init__(self, data=None, url=None, filename=None, metadata=None):
422 461 def warn():
423 462 if not data:
424 463 return False
425 464
426 465 #
427 466 # Avoid calling lower() on the entire data, because it could be a
428 467 # long string and we're only interested in its beginning and end.
429 468 #
430 469 prefix = data[:10].lower()
431 470 suffix = data[-10:].lower()
432 471 return prefix.startswith("<iframe ") and suffix.endswith("</iframe>")
433 472
434 473 if warn():
435 474 warnings.warn("Consider using IPython.display.IFrame instead")
436 475 super(HTML, self).__init__(data=data, url=url, filename=filename, metadata=metadata)
437 476
438 477 def _repr_html_(self):
439 478 return self._data_and_metadata()
440 479
441 480 def __html__(self):
442 481 """
443 482 This method exists to inform other HTML-using modules (e.g. Markupsafe,
444 483 htmltag, etc) that this object is HTML and does not need things like
445 484 special characters (<>&) escaped.
446 485 """
447 486 return self._repr_html_()
448 487
449 488
450 489 class Markdown(TextDisplayObject):
451 490
452 491 def _repr_markdown_(self):
453 492 return self._data_and_metadata()
454 493
455 494
456 495 class Math(TextDisplayObject):
457 496
458 497 def _repr_latex_(self):
459 498 s = r"$\displaystyle %s$" % self.data.strip('$')
460 499 if self.metadata:
461 500 return s, deepcopy(self.metadata)
462 501 else:
463 502 return s
464 503
465 504
466 505 class Latex(TextDisplayObject):
467 506
468 507 def _repr_latex_(self):
469 508 return self._data_and_metadata()
470 509
471 510
472 511 class SVG(DisplayObject):
473 512 """Embed an SVG into the display.
474 513
475 514 Note if you just want to view a svg image via a URL use `:class:Image` with
476 515 a url=URL keyword argument.
477 516 """
478 517
479 518 _read_flags = 'rb'
480 519 # wrap data in a property, which extracts the <svg> tag, discarding
481 520 # document headers
482 521 _data = None
483 522
484 523 @property
485 524 def data(self):
486 525 return self._data
487 526
488 527 @data.setter
489 528 def data(self, svg):
490 529 if svg is None:
491 530 self._data = None
492 531 return
493 532 # parse into dom object
494 533 from xml.dom import minidom
495 534 x = minidom.parseString(svg)
496 535 # get svg tag (should be 1)
497 536 found_svg = x.getElementsByTagName('svg')
498 537 if found_svg:
499 538 svg = found_svg[0].toxml()
500 539 else:
501 540 # fallback on the input, trust the user
502 541 # but this is probably an error.
503 542 pass
504 543 svg = cast_unicode(svg)
505 544 self._data = svg
506 545
507 546 def _repr_svg_(self):
508 547 return self._data_and_metadata()
509 548
510 549 class ProgressBar(DisplayObject):
511 550 """Progressbar supports displaying a progressbar like element
512 551 """
513 552 def __init__(self, total):
514 553 """Creates a new progressbar
515 554
516 555 Parameters
517 556 ----------
518 557 total : int
519 558 maximum size of the progressbar
520 559 """
521 560 self.total = total
522 561 self._progress = 0
523 562 self.html_width = '60ex'
524 563 self.text_width = 60
525 564 self._display_id = hexlify(os.urandom(8)).decode('ascii')
526 565
527 566 def __repr__(self):
528 567 fraction = self.progress / self.total
529 568 filled = '=' * int(fraction * self.text_width)
530 569 rest = ' ' * (self.text_width - len(filled))
531 570 return '[{}{}] {}/{}'.format(
532 571 filled, rest,
533 572 self.progress, self.total,
534 573 )
535 574
536 575 def _repr_html_(self):
537 576 return "<progress style='width:{}' max='{}' value='{}'></progress>".format(
538 577 self.html_width, self.total, self.progress)
539 578
540 579 def display(self):
541 580 display_functions.display(self, display_id=self._display_id)
542 581
543 582 def update(self):
544 583 display_functions.display(self, display_id=self._display_id, update=True)
545 584
546 585 @property
547 586 def progress(self):
548 587 return self._progress
549 588
550 589 @progress.setter
551 590 def progress(self, value):
552 591 self._progress = value
553 592 self.update()
554 593
555 594 def __iter__(self):
556 595 self.display()
557 596 self._progress = -1 # First iteration is 0
558 597 return self
559 598
560 599 def __next__(self):
561 600 """Returns current value and increments display by one."""
562 601 self.progress += 1
563 602 if self.progress < self.total:
564 603 return self.progress
565 604 else:
566 605 raise StopIteration()
567 606
568 607 class JSON(DisplayObject):
569 608 """JSON expects a JSON-able dict or list
570 609
571 610 not an already-serialized JSON string.
572 611
573 612 Scalar types (None, number, string) are not allowed, only dict or list containers.
574 613 """
575 614 # wrap data in a property, which warns about passing already-serialized JSON
576 615 _data = None
577 616 def __init__(self, data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs):
578 617 """Create a JSON display object given raw data.
579 618
580 619 Parameters
581 620 ----------
582 621 data : dict or list
583 622 JSON data to display. Not an already-serialized JSON string.
584 623 Scalar types (None, number, string) are not allowed, only dict
585 624 or list containers.
586 625 url : unicode
587 626 A URL to download the data from.
588 627 filename : unicode
589 628 Path to a local file to load the data from.
590 629 expanded : boolean
591 630 Metadata to control whether a JSON display component is expanded.
592 631 metadata : dict
593 632 Specify extra metadata to attach to the json display object.
594 633 root : str
595 634 The name of the root element of the JSON tree
596 635 """
597 636 self.metadata = {
598 637 'expanded': expanded,
599 638 'root': root,
600 639 }
601 640 if metadata:
602 641 self.metadata.update(metadata)
603 642 if kwargs:
604 643 self.metadata.update(kwargs)
605 644 super(JSON, self).__init__(data=data, url=url, filename=filename)
606 645
607 646 def _check_data(self):
608 647 if self.data is not None and not isinstance(self.data, (dict, list)):
609 648 raise TypeError("%s expects JSONable dict or list, not %r" % (self.__class__.__name__, self.data))
610 649
611 650 @property
612 651 def data(self):
613 652 return self._data
614 653
615 654 @data.setter
616 655 def data(self, data):
617 656 if isinstance(data, (Path, PurePath)):
618 657 data = str(data)
619 658
620 659 if isinstance(data, str):
621 660 if self.filename is None and self.url is None:
622 661 warnings.warn("JSON expects JSONable dict or list, not JSON strings")
623 662 data = json.loads(data)
624 663 self._data = data
625 664
626 665 def _data_and_metadata(self):
627 666 return self.data, self.metadata
628 667
629 668 def _repr_json_(self):
630 669 return self._data_and_metadata()
631 670
632 671
633 672 _css_t = """var link = document.createElement("link");
634 673 link.rel = "stylesheet";
635 674 link.type = "text/css";
636 675 link.href = "%s";
637 676 document.head.appendChild(link);
638 677 """
639 678
640 679 _lib_t1 = """new Promise(function(resolve, reject) {
641 680 var script = document.createElement("script");
642 681 script.onload = resolve;
643 682 script.onerror = reject;
644 683 script.src = "%s";
645 684 document.head.appendChild(script);
646 685 }).then(() => {
647 686 """
648 687
649 688 _lib_t2 = """
650 689 });"""
651 690
652 691 class GeoJSON(JSON):
653 692 """GeoJSON expects JSON-able dict
654 693
655 694 not an already-serialized JSON string.
656 695
657 696 Scalar types (None, number, string) are not allowed, only dict containers.
658 697 """
659 698
660 699 def __init__(self, *args, **kwargs):
661 700 """Create a GeoJSON display object given raw data.
662 701
663 702 Parameters
664 703 ----------
665 704 data : dict or list
666 705 VegaLite data. Not an already-serialized JSON string.
667 706 Scalar types (None, number, string) are not allowed, only dict
668 707 or list containers.
669 708 url_template : string
670 709 Leaflet TileLayer URL template: http://leafletjs.com/reference.html#url-template
671 710 layer_options : dict
672 711 Leaflet TileLayer options: http://leafletjs.com/reference.html#tilelayer-options
673 712 url : unicode
674 713 A URL to download the data from.
675 714 filename : unicode
676 715 Path to a local file to load the data from.
677 716 metadata : dict
678 717 Specify extra metadata to attach to the json display object.
679 718
680 719 Examples
681 720 --------
682 721 The following will display an interactive map of Mars with a point of
683 722 interest on frontend that do support GeoJSON display.
684 723
685 724 >>> from IPython.display import GeoJSON
686 725
687 726 >>> GeoJSON(data={
688 727 ... "type": "Feature",
689 728 ... "geometry": {
690 729 ... "type": "Point",
691 730 ... "coordinates": [-81.327, 296.038]
692 731 ... }
693 732 ... },
694 733 ... url_template="http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/{basemap_id}/{z}/{x}/{y}.png",
695 734 ... layer_options={
696 735 ... "basemap_id": "celestia_mars-shaded-16k_global",
697 736 ... "attribution" : "Celestia/praesepe",
698 737 ... "minZoom" : 0,
699 738 ... "maxZoom" : 18,
700 739 ... })
701 740 <IPython.core.display.GeoJSON object>
702 741
703 742 In the terminal IPython, you will only see the text representation of
704 743 the GeoJSON object.
705 744
706 745 """
707 746
708 747 super(GeoJSON, self).__init__(*args, **kwargs)
709 748
710 749
711 750 def _ipython_display_(self):
712 751 bundle = {
713 752 'application/geo+json': self.data,
714 753 'text/plain': '<IPython.display.GeoJSON object>'
715 754 }
716 755 metadata = {
717 756 'application/geo+json': self.metadata
718 757 }
719 758 display_functions.display(bundle, metadata=metadata, raw=True)
720 759
721 760 class Javascript(TextDisplayObject):
722 761
723 762 def __init__(self, data=None, url=None, filename=None, lib=None, css=None):
724 763 """Create a Javascript display object given raw data.
725 764
726 765 When this object is returned by an expression or passed to the
727 766 display function, it will result in the data being displayed
728 767 in the frontend. If the data is a URL, the data will first be
729 768 downloaded and then displayed.
730 769
731 770 In the Notebook, the containing element will be available as `element`,
732 771 and jQuery will be available. Content appended to `element` will be
733 772 visible in the output area.
734 773
735 774 Parameters
736 775 ----------
737 776 data : unicode, str or bytes
738 777 The Javascript source code or a URL to download it from.
739 778 url : unicode
740 779 A URL to download the data from.
741 780 filename : unicode
742 781 Path to a local file to load the data from.
743 782 lib : list or str
744 783 A sequence of Javascript library URLs to load asynchronously before
745 784 running the source code. The full URLs of the libraries should
746 785 be given. A single Javascript library URL can also be given as a
747 786 string.
748 787 css : list or str
749 788 A sequence of css files to load before running the source code.
750 789 The full URLs of the css files should be given. A single css URL
751 790 can also be given as a string.
752 791 """
753 792 if isinstance(lib, str):
754 793 lib = [lib]
755 794 elif lib is None:
756 795 lib = []
757 796 if isinstance(css, str):
758 797 css = [css]
759 798 elif css is None:
760 799 css = []
761 800 if not isinstance(lib, (list,tuple)):
762 801 raise TypeError('expected sequence, got: %r' % lib)
763 802 if not isinstance(css, (list,tuple)):
764 803 raise TypeError('expected sequence, got: %r' % css)
765 804 self.lib = lib
766 805 self.css = css
767 806 super(Javascript, self).__init__(data=data, url=url, filename=filename)
768 807
769 808 def _repr_javascript_(self):
770 809 r = ''
771 810 for c in self.css:
772 811 r += _css_t % c
773 812 for l in self.lib:
774 813 r += _lib_t1 % l
775 814 r += self.data
776 815 r += _lib_t2*len(self.lib)
777 816 return r
778 817
779 # constants for identifying png/jpeg data
780 _PNG = b'\x89PNG\r\n\x1a\n'
781 _JPEG = b'\xff\xd8'
818
819 # constants for identifying png/jpeg/gif/webp data
820 _PNG = b"\x89PNG\r\n\x1a\n"
821 _JPEG = b"\xff\xd8"
822 _GIF1 = b"GIF87a"
823 _GIF2 = b"GIF89a"
824 _WEBP = b"WEBP"
825
782 826
783 827 def _pngxy(data):
784 828 """read the (width, height) from a PNG header"""
785 829 ihdr = data.index(b'IHDR')
786 830 # next 8 bytes are width/height
787 831 return struct.unpack('>ii', data[ihdr+4:ihdr+12])
788 832
833
789 834 def _jpegxy(data):
790 835 """read the (width, height) from a JPEG header"""
791 836 # adapted from http://www.64lines.com/jpeg-width-height
792 837
793 838 idx = 4
794 839 while True:
795 840 block_size = struct.unpack('>H', data[idx:idx+2])[0]
796 841 idx = idx + block_size
797 842 if data[idx:idx+2] == b'\xFF\xC0':
798 843 # found Start of Frame
799 844 iSOF = idx
800 845 break
801 846 else:
802 847 # read another block
803 848 idx += 2
804 849
805 850 h, w = struct.unpack('>HH', data[iSOF+5:iSOF+9])
806 851 return w, h
807 852
853
808 854 def _gifxy(data):
809 855 """read the (width, height) from a GIF header"""
810 856 return struct.unpack('<HH', data[6:10])
811 857
812 858
859 def _webpxy(data):
860 """read the (width, height) from a WEBP header"""
861 if data[12:16] == b"VP8 ":
862 width, height = struct.unpack("<HH", data[24:30])
863 width = width & 0x3FFF
864 height = height & 0x3FFF
865 return (width, height)
866 elif data[12:16] == b"VP8L":
867 size_info = struct.unpack("<I", data[21:25])[0]
868 width = 1 + ((size_info & 0x3F) << 8) | (size_info >> 24)
869 height = 1 + (
870 (((size_info >> 8) & 0xF) << 10)
871 | (((size_info >> 14) & 0x3FC) << 2)
872 | ((size_info >> 22) & 0x3)
873 )
874 return (width, height)
875 else:
876 raise ValueError("Not a valid WEBP header")
877
878
813 879 class Image(DisplayObject):
814 880
815 _read_flags = 'rb'
816 _FMT_JPEG = u'jpeg'
817 _FMT_PNG = u'png'
818 _FMT_GIF = u'gif'
819 _ACCEPTABLE_EMBEDDINGS = [_FMT_JPEG, _FMT_PNG, _FMT_GIF]
881 _read_flags = "rb"
882 _FMT_JPEG = "jpeg"
883 _FMT_PNG = "png"
884 _FMT_GIF = "gif"
885 _FMT_WEBP = "webp"
886 _ACCEPTABLE_EMBEDDINGS = [_FMT_JPEG, _FMT_PNG, _FMT_GIF, _FMT_WEBP]
820 887 _MIMETYPES = {
821 _FMT_PNG: 'image/png',
822 _FMT_JPEG: 'image/jpeg',
823 _FMT_GIF: 'image/gif',
888 _FMT_PNG: "image/png",
889 _FMT_JPEG: "image/jpeg",
890 _FMT_GIF: "image/gif",
891 _FMT_WEBP: "image/webp",
824 892 }
825 893
826 894 def __init__(
827 895 self,
828 896 data=None,
829 897 url=None,
830 898 filename=None,
831 899 format=None,
832 900 embed=None,
833 901 width=None,
834 902 height=None,
835 903 retina=False,
836 904 unconfined=False,
837 905 metadata=None,
838 906 alt=None,
839 907 ):
840 """Create a PNG/JPEG/GIF image object given raw data.
908 """Create a PNG/JPEG/GIF/WEBP image object given raw data.
841 909
842 910 When this object is returned by an input cell or passed to the
843 911 display function, it will result in the image being displayed
844 912 in the frontend.
845 913
846 914 Parameters
847 915 ----------
848 916 data : unicode, str or bytes
849 917 The raw image data or a URL or filename to load the data from.
850 918 This always results in embedded image data.
851 919
852 920 url : unicode
853 921 A URL to download the data from. If you specify `url=`,
854 922 the image data will not be embedded unless you also specify `embed=True`.
855 923
856 924 filename : unicode
857 925 Path to a local file to load the data from.
858 926 Images from a file are always embedded.
859 927
860 928 format : unicode
861 The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given
929 The format of the image data (png/jpeg/jpg/gif/webp). If a filename or URL is given
862 930 for format will be inferred from the filename extension.
863 931
864 932 embed : bool
865 933 Should the image data be embedded using a data URI (True) or be
866 934 loaded using an <img> tag. Set this to True if you want the image
867 935 to be viewable later with no internet connection in the notebook.
868 936
869 937 Default is `True`, unless the keyword argument `url` is set, then
870 938 default value is `False`.
871 939
872 940 Note that QtConsole is not able to display images if `embed` is set to `False`
873 941
874 942 width : int
875 943 Width in pixels to which to constrain the image in html
876 944
877 945 height : int
878 946 Height in pixels to which to constrain the image in html
879 947
880 948 retina : bool
881 949 Automatically set the width and height to half of the measured
882 950 width and height.
883 951 This only works for embedded images because it reads the width/height
884 952 from image data.
885 953 For non-embedded images, you can just set the desired display width
886 954 and height directly.
887 955
888 956 unconfined : bool
889 957 Set unconfined=True to disable max-width confinement of the image.
890 958
891 959 metadata : dict
892 960 Specify extra metadata to attach to the image.
893 961
894 962 alt : unicode
895 963 Alternative text for the image, for use by screen readers.
896 964
897 965 Examples
898 966 --------
899 967 embedded image data, works in qtconsole and notebook
900 968 when passed positionally, the first arg can be any of raw image data,
901 969 a URL, or a filename from which to load image data.
902 970 The result is always embedding image data for inline images.
903 971
904 972 >>> Image('https://www.google.fr/images/srpr/logo3w.png') # doctest: +SKIP
905 973 <IPython.core.display.Image object>
906 974
907 975 >>> Image('/path/to/image.jpg')
908 976 <IPython.core.display.Image object>
909 977
910 978 >>> Image(b'RAW_PNG_DATA...')
911 979 <IPython.core.display.Image object>
912 980
913 981 Specifying Image(url=...) does not embed the image data,
914 982 it only generates ``<img>`` tag with a link to the source.
915 983 This will not work in the qtconsole or offline.
916 984
917 985 >>> Image(url='https://www.google.fr/images/srpr/logo3w.png')
918 986 <IPython.core.display.Image object>
919 987
920 988 """
921 989 if isinstance(data, (Path, PurePath)):
922 990 data = str(data)
923 991
924 992 if filename is not None:
925 993 ext = self._find_ext(filename)
926 994 elif url is not None:
927 995 ext = self._find_ext(url)
928 996 elif data is None:
929 997 raise ValueError("No image data found. Expecting filename, url, or data.")
930 998 elif isinstance(data, str) and (
931 999 data.startswith('http') or _safe_exists(data)
932 1000 ):
933 1001 ext = self._find_ext(data)
934 1002 else:
935 1003 ext = None
936 1004
937 1005 if format is None:
938 1006 if ext is not None:
939 1007 if ext == u'jpg' or ext == u'jpeg':
940 1008 format = self._FMT_JPEG
941 1009 elif ext == u'png':
942 1010 format = self._FMT_PNG
943 1011 elif ext == u'gif':
944 1012 format = self._FMT_GIF
1013 elif ext == "webp":
1014 format = self._FMT_WEBP
945 1015 else:
946 1016 format = ext.lower()
947 1017 elif isinstance(data, bytes):
948 1018 # infer image type from image data header,
949 1019 # only if format has not been specified.
950 1020 if data[:2] == _JPEG:
951 1021 format = self._FMT_JPEG
1022 elif data[:8] == _PNG:
1023 format = self._FMT_PNG
1024 elif data[8:12] == _WEBP:
1025 format = self._FMT_WEBP
1026 elif data[:6] == _GIF1 or data[:6] == _GIF2:
1027 format = self._FMT_GIF
952 1028
953 1029 # failed to detect format, default png
954 1030 if format is None:
955 1031 format = self._FMT_PNG
956 1032
957 1033 if format.lower() == 'jpg':
958 1034 # jpg->jpeg
959 1035 format = self._FMT_JPEG
960 1036
961 1037 self.format = format.lower()
962 1038 self.embed = embed if embed is not None else (url is None)
963 1039
964 1040 if self.embed and self.format not in self._ACCEPTABLE_EMBEDDINGS:
965 1041 raise ValueError("Cannot embed the '%s' image format" % (self.format))
966 1042 if self.embed:
967 1043 self._mimetype = self._MIMETYPES.get(self.format)
968 1044
969 1045 self.width = width
970 1046 self.height = height
971 1047 self.retina = retina
972 1048 self.unconfined = unconfined
973 1049 self.alt = alt
974 1050 super(Image, self).__init__(data=data, url=url, filename=filename,
975 1051 metadata=metadata)
976 1052
977 1053 if self.width is None and self.metadata.get('width', {}):
978 1054 self.width = metadata['width']
979 1055
980 1056 if self.height is None and self.metadata.get('height', {}):
981 1057 self.height = metadata['height']
982 1058
983 1059 if self.alt is None and self.metadata.get("alt", {}):
984 1060 self.alt = metadata["alt"]
985 1061
986 1062 if retina:
987 1063 self._retina_shape()
988 1064
989 1065
990 1066 def _retina_shape(self):
991 1067 """load pixel-doubled width and height from image data"""
992 1068 if not self.embed:
993 1069 return
994 1070 if self.format == self._FMT_PNG:
995 1071 w, h = _pngxy(self.data)
996 1072 elif self.format == self._FMT_JPEG:
997 1073 w, h = _jpegxy(self.data)
998 1074 elif self.format == self._FMT_GIF:
999 1075 w, h = _gifxy(self.data)
1000 1076 else:
1001 1077 # retina only supports png
1002 1078 return
1003 1079 self.width = w // 2
1004 1080 self.height = h // 2
1005 1081
1006 1082 def reload(self):
1007 1083 """Reload the raw data from file or URL."""
1008 1084 if self.embed:
1009 1085 super(Image,self).reload()
1010 1086 if self.retina:
1011 1087 self._retina_shape()
1012 1088
1013 1089 def _repr_html_(self):
1014 1090 if not self.embed:
1015 1091 width = height = klass = alt = ""
1016 1092 if self.width:
1017 1093 width = ' width="%d"' % self.width
1018 1094 if self.height:
1019 1095 height = ' height="%d"' % self.height
1020 1096 if self.unconfined:
1021 1097 klass = ' class="unconfined"'
1022 1098 if self.alt:
1023 1099 alt = ' alt="%s"' % html.escape(self.alt)
1024 1100 return '<img src="{url}"{width}{height}{klass}{alt}/>'.format(
1025 1101 url=self.url,
1026 1102 width=width,
1027 1103 height=height,
1028 1104 klass=klass,
1029 1105 alt=alt,
1030 1106 )
1031 1107
1032 1108 def _repr_mimebundle_(self, include=None, exclude=None):
1033 1109 """Return the image as a mimebundle
1034 1110
1035 1111 Any new mimetype support should be implemented here.
1036 1112 """
1037 1113 if self.embed:
1038 1114 mimetype = self._mimetype
1039 1115 data, metadata = self._data_and_metadata(always_both=True)
1040 1116 if metadata:
1041 1117 metadata = {mimetype: metadata}
1042 1118 return {mimetype: data}, metadata
1043 1119 else:
1044 1120 return {'text/html': self._repr_html_()}
1045 1121
1046 1122 def _data_and_metadata(self, always_both=False):
1047 1123 """shortcut for returning metadata with shape information, if defined"""
1048 1124 try:
1049 1125 b64_data = b2a_base64(self.data, newline=False).decode("ascii")
1050 1126 except TypeError as e:
1051 1127 raise FileNotFoundError(
1052 1128 "No such file or directory: '%s'" % (self.data)) from e
1053 1129 md = {}
1054 1130 if self.metadata:
1055 1131 md.update(self.metadata)
1056 1132 if self.width:
1057 1133 md['width'] = self.width
1058 1134 if self.height:
1059 1135 md['height'] = self.height
1060 1136 if self.unconfined:
1061 1137 md['unconfined'] = self.unconfined
1062 1138 if self.alt:
1063 1139 md["alt"] = self.alt
1064 1140 if md or always_both:
1065 1141 return b64_data, md
1066 1142 else:
1067 1143 return b64_data
1068 1144
1069 1145 def _repr_png_(self):
1070 1146 if self.embed and self.format == self._FMT_PNG:
1071 1147 return self._data_and_metadata()
1072 1148
1073 1149 def _repr_jpeg_(self):
1074 1150 if self.embed and self.format == self._FMT_JPEG:
1075 1151 return self._data_and_metadata()
1076 1152
1077 1153 def _find_ext(self, s):
1078 1154 base, ext = splitext(s)
1079 1155
1080 1156 if not ext:
1081 1157 return base
1082 1158
1083 1159 # `splitext` includes leading period, so we skip it
1084 1160 return ext[1:].lower()
1085 1161
1086 1162
1087 1163 class Video(DisplayObject):
1088 1164
1089 1165 def __init__(self, data=None, url=None, filename=None, embed=False,
1090 1166 mimetype=None, width=None, height=None, html_attributes="controls"):
1091 1167 """Create a video object given raw data or an URL.
1092 1168
1093 1169 When this object is returned by an input cell or passed to the
1094 1170 display function, it will result in the video being displayed
1095 1171 in the frontend.
1096 1172
1097 1173 Parameters
1098 1174 ----------
1099 1175 data : unicode, str or bytes
1100 1176 The raw video data or a URL or filename to load the data from.
1101 1177 Raw data will require passing ``embed=True``.
1102 1178
1103 1179 url : unicode
1104 1180 A URL for the video. If you specify ``url=``,
1105 1181 the image data will not be embedded.
1106 1182
1107 1183 filename : unicode
1108 1184 Path to a local file containing the video.
1109 1185 Will be interpreted as a local URL unless ``embed=True``.
1110 1186
1111 1187 embed : bool
1112 1188 Should the video be embedded using a data URI (True) or be
1113 1189 loaded using a <video> tag (False).
1114 1190
1115 1191 Since videos are large, embedding them should be avoided, if possible.
1116 1192 You must confirm embedding as your intention by passing ``embed=True``.
1117 1193
1118 1194 Local files can be displayed with URLs without embedding the content, via::
1119 1195
1120 1196 Video('./video.mp4')
1121 1197
1122 1198 mimetype : unicode
1123 1199 Specify the mimetype for embedded videos.
1124 1200 Default will be guessed from file extension, if available.
1125 1201
1126 1202 width : int
1127 1203 Width in pixels to which to constrain the video in HTML.
1128 1204 If not supplied, defaults to the width of the video.
1129 1205
1130 1206 height : int
1131 1207 Height in pixels to which to constrain the video in html.
1132 1208 If not supplied, defaults to the height of the video.
1133 1209
1134 1210 html_attributes : str
1135 1211 Attributes for the HTML ``<video>`` block.
1136 1212 Default: ``"controls"`` to get video controls.
1137 1213 Other examples: ``"controls muted"`` for muted video with controls,
1138 1214 ``"loop autoplay"`` for looping autoplaying video without controls.
1139 1215
1140 1216 Examples
1141 1217 --------
1142 1218 ::
1143 1219
1144 1220 Video('https://archive.org/download/Sita_Sings_the_Blues/Sita_Sings_the_Blues_small.mp4')
1145 1221 Video('path/to/video.mp4')
1146 1222 Video('path/to/video.mp4', embed=True)
1147 1223 Video('path/to/video.mp4', embed=True, html_attributes="controls muted autoplay")
1148 1224 Video(b'raw-videodata', embed=True)
1149 1225 """
1150 1226 if isinstance(data, (Path, PurePath)):
1151 1227 data = str(data)
1152 1228
1153 1229 if url is None and isinstance(data, str) and data.startswith(('http:', 'https:')):
1154 1230 url = data
1155 1231 data = None
1156 1232 elif data is not None and os.path.exists(data):
1157 1233 filename = data
1158 1234 data = None
1159 1235
1160 1236 if data and not embed:
1161 1237 msg = ''.join([
1162 1238 "To embed videos, you must pass embed=True ",
1163 1239 "(this may make your notebook files huge)\n",
1164 1240 "Consider passing Video(url='...')",
1165 1241 ])
1166 1242 raise ValueError(msg)
1167 1243
1168 1244 self.mimetype = mimetype
1169 1245 self.embed = embed
1170 1246 self.width = width
1171 1247 self.height = height
1172 1248 self.html_attributes = html_attributes
1173 1249 super(Video, self).__init__(data=data, url=url, filename=filename)
1174 1250
1175 1251 def _repr_html_(self):
1176 1252 width = height = ''
1177 1253 if self.width:
1178 1254 width = ' width="%d"' % self.width
1179 1255 if self.height:
1180 1256 height = ' height="%d"' % self.height
1181 1257
1182 1258 # External URLs and potentially local files are not embedded into the
1183 1259 # notebook output.
1184 1260 if not self.embed:
1185 1261 url = self.url if self.url is not None else self.filename
1186 1262 output = """<video src="{0}" {1} {2} {3}>
1187 1263 Your browser does not support the <code>video</code> element.
1188 1264 </video>""".format(url, self.html_attributes, width, height)
1189 1265 return output
1190 1266
1191 1267 # Embedded videos are base64-encoded.
1192 1268 mimetype = self.mimetype
1193 1269 if self.filename is not None:
1194 1270 if not mimetype:
1195 1271 mimetype, _ = mimetypes.guess_type(self.filename)
1196 1272
1197 1273 with open(self.filename, 'rb') as f:
1198 1274 video = f.read()
1199 1275 else:
1200 1276 video = self.data
1201 1277 if isinstance(video, str):
1202 1278 # unicode input is already b64-encoded
1203 1279 b64_video = video
1204 1280 else:
1205 1281 b64_video = b2a_base64(video, newline=False).decode("ascii").rstrip()
1206 1282
1207 1283 output = """<video {0} {1} {2}>
1208 1284 <source src="data:{3};base64,{4}" type="{3}">
1209 1285 Your browser does not support the video tag.
1210 1286 </video>""".format(self.html_attributes, width, height, mimetype, b64_video)
1211 1287 return output
1212 1288
1213 1289 def reload(self):
1214 1290 # TODO
1215 1291 pass
1216 1292
1217 1293
1218 1294 @skip_doctest
1219 1295 def set_matplotlib_formats(*formats, **kwargs):
1220 1296 """
1221 1297 .. deprecated:: 7.23
1222 1298
1223 1299 use `matplotlib_inline.backend_inline.set_matplotlib_formats()`
1224 1300
1225 1301 Select figure formats for the inline backend. Optionally pass quality for JPEG.
1226 1302
1227 1303 For example, this enables PNG and JPEG output with a JPEG quality of 90%::
1228 1304
1229 1305 In [1]: set_matplotlib_formats('png', 'jpeg', quality=90)
1230 1306
1231 1307 To set this in your config files use the following::
1232 1308
1233 1309 c.InlineBackend.figure_formats = {'png', 'jpeg'}
1234 1310 c.InlineBackend.print_figure_kwargs.update({'quality' : 90})
1235 1311
1236 1312 Parameters
1237 1313 ----------
1238 1314 *formats : strs
1239 1315 One or more figure formats to enable: 'png', 'retina', 'jpeg', 'svg', 'pdf'.
1240 1316 **kwargs
1241 1317 Keyword args will be relayed to ``figure.canvas.print_figure``.
1242 1318 """
1243 1319 warnings.warn(
1244 1320 "`set_matplotlib_formats` is deprecated since IPython 7.23, directly "
1245 1321 "use `matplotlib_inline.backend_inline.set_matplotlib_formats()`",
1246 1322 DeprecationWarning,
1247 1323 stacklevel=2,
1248 1324 )
1249 1325
1250 1326 from matplotlib_inline.backend_inline import (
1251 1327 set_matplotlib_formats as set_matplotlib_formats_orig,
1252 1328 )
1253 1329
1254 1330 set_matplotlib_formats_orig(*formats, **kwargs)
1255 1331
1256 1332 @skip_doctest
1257 1333 def set_matplotlib_close(close=True):
1258 1334 """
1259 1335 .. deprecated:: 7.23
1260 1336
1261 1337 use `matplotlib_inline.backend_inline.set_matplotlib_close()`
1262 1338
1263 1339 Set whether the inline backend closes all figures automatically or not.
1264 1340
1265 1341 By default, the inline backend used in the IPython Notebook will close all
1266 1342 matplotlib figures automatically after each cell is run. This means that
1267 1343 plots in different cells won't interfere. Sometimes, you may want to make
1268 1344 a plot in one cell and then refine it in later cells. This can be accomplished
1269 1345 by::
1270 1346
1271 1347 In [1]: set_matplotlib_close(False)
1272 1348
1273 1349 To set this in your config files use the following::
1274 1350
1275 1351 c.InlineBackend.close_figures = False
1276 1352
1277 1353 Parameters
1278 1354 ----------
1279 1355 close : bool
1280 1356 Should all matplotlib figures be automatically closed after each cell is
1281 1357 run?
1282 1358 """
1283 1359 warnings.warn(
1284 1360 "`set_matplotlib_close` is deprecated since IPython 7.23, directly "
1285 1361 "use `matplotlib_inline.backend_inline.set_matplotlib_close()`",
1286 1362 DeprecationWarning,
1287 1363 stacklevel=2,
1288 1364 )
1289 1365
1290 1366 from matplotlib_inline.backend_inline import (
1291 1367 set_matplotlib_close as set_matplotlib_close_orig,
1292 1368 )
1293 1369
1294 1370 set_matplotlib_close_orig(close)
@@ -1,2397 +1,2406
1 1 ============
2 2 8.x Series
3 3 ============
4
5 .. _version 8.29:
6
7 IPython 8.29
8 ============
9
10
11 - Add support for WEBP to ``IPython.display.Image``. :ghpull:`14526`
12
4 13 .. _version 8.28:
5 14
6 15 IPython 8.28
7 16 ============
8 17
9 18 Slight delay of this September release as I was busy at Pydata Paris last week.
10 19 Not many user visible changes for this release, a couple of bug fixes and
11 20 workaround:
12 21
13 22 - :ghpull:`14480` AssertionError: assert _xterm_term_title_saved in WSL – It is
14 23 unclear why the terminal title is not saved in WSL, if you've WSL experience
15 24 we'd love your feedback and help to not just ignore an error
16 25 - :ghpull:`14510` Fix use of pyside6 >= 6.7.0
17 26 - :ghpull:`14518` Make values public (_tb_highlight & _tb_highlight_style)
18 27 - :ghpull:`14515` Use environment variable to identify conda / mamba
19 28
20 29
21 30 As usual you can find the full list of PRs on GitHub under `the 8.28
22 31 <https://github.com/ipython/ipython/milestone/135?closed=1>`__ milestone.
23 32
24 33 For something completely different
25 34 ----------------------------------
26 35
27 36 One of the first works of Science Fiction (`Frankenstein
28 37 <https://en.wikipedia.org/wiki/Frankenstein>`__), was written by `Mary Shelley
29 38 <https://en.wikipedia.org/wiki/Mary_Shelley>`__ when she was 18, before being
30 39 published in London on 1 January 1818 when she was 20. This is often overlooked,
31 40 and the role of founders of science fiction attribute to Edgar Allan Poe and
32 41 Jules Verne despite being published later.
33 42
34 43 Thanks
35 44 ------
36 45
37 46 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
38 47 work on IPython and related libraries.
39 48
40 49
41 50 .. _version 8.27:
42 51
43 52 IPython 8.27
44 53 ============
45 54
46 55 New release of IPython after a month off (not enough changes). We can see a few
47 56 important changes for this release.
48 57
49 58 - autocall was being call getitem, :ghpull:`14486`
50 59 - Only copy files in startup dir if we just created it. :ghpull:`14497`
51 60 - Fix some tests on Python 3.13 RC1 :ghpull:`14504`; this one I guess make this
52 61 the first IPython release officially compatible with Python 3.13; you will
53 62 need the most recent ``executing`` and ``stack_data``, we won't pin to avoid
54 63 forcing user of older Python version to upgrade.
55 64
56 65
57 66 As usual you can find the full list of PRs on GitHub under `the 8.27
58 67 <https://github.com/ipython/ipython/milestone/134?closed=1>`__ milestone.
59 68
60 69 Thanks
61 70 ------
62 71
63 72 Many thanks to `@Kleirre <https://github.com/Kleirre>`__ our June intern for
64 73 doing her first contribution to open source, doing the releases notes and
65 74 release. I guess you didn't even notice it was not me who released :-). I wish
66 75 her all the best in her future endeavor and look forward for her work in
67 76 astrophysics.
68 77
69 78 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
70 79 work on IPython and related libraries.
71 80
72 81 .. _version 8.26:
73 82
74 83 IPython 8.26
75 84 ============
76 85
77 86 Hey, the release of IPython for this month is here! (I know you were waiting for it)
78 87
79 88 - :ghpull:`14453` bugfix for call to structured_traceback
80 89
81 90 - :ghpull:`14466` fixed honoring custom repr for NamedTuple if assigned by partialmethod
82 91
83 92 - :ghpull:`14451` Convert matplotlib gui name in enable_gui
84 93
85 94 As usual you can find the full list of PRs on GitHub under `the 8.26
86 95 <https://github.com/ipython/ipython/milestone/133?closed=1>`__ milestone.
87 96
88 97 Thanks
89 98 ------
90 99
91 100 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
92 101 work on IPython and related libraries.
93 102
94 103
95 104 .. _version 8.25:
96 105
97 106 IPython 8.25
98 107 ============
99 108
100 109 Mostly internal changes for this end of may release of IPython.
101 110
102 111 We'll count about a dozen PRs for this moth, with small bugfixes related to
103 112 matplotlib fixes.
104 113
105 114 Of notable interest,
106 115
107 116 - :ghpull:`14426` replaces the unicode micro symbol with greek letter mu,
108 117 visually identical but should fix nfkc normalisations issues.
109 118
110 119 - :ghpull:`14444` introduces ``intersphinx_registry`` as a new dependency
111 120 which is recommended only to build documentation.
112 121
113 122 As usual you can find the full list of PRs on GitHub under `the 8.25
114 123 <https://github.com/ipython/ipython/milestone/132?closed=1>`__ milestone.
115 124
116 125 Thanks
117 126 ------
118 127
119 128 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
120 129 work on IPython and related libraries.
121 130
122 131
123 132 .. _version 8.24:
124 133
125 134 IPython 8.24
126 135 ============
127 136
128 137 Back on regular release schedule, as usual month releases are relatively tiny.
129 138
130 139 The biggest change is the move of the matplotlib backend handling from IPython
131 140 to matplotlib. :ghpull:`14371` :ghpull:`14403`.
132 141
133 142 We will note:
134 143
135 144 - pytest 8 compatibility :ghpull:`14413`
136 145 - ``typing-extension`` now needs 4.6 or newer. It was already the case, but not
137 146 explicated. :ghpull:`14380`
138 147 - Attempt to speed running code under debugger in some cases. :ghpull:`14386`
139 148 :ghpull:`14418`.
140 149 - Multiple fixes to documentation for ipyparallel, simple_prompt and emacs
141 150 :ghpull:`14384` :ghpull:`14404` :ghpull:`14407`
142 151 - Maintenance and cleanup of debugger :ghpull:`14387` :ghpull:`14393`
143 152
144 153 As usual you can find the full list of PRs on GitHub under `the 8.24
145 154 <https://github.com/ipython/ipython/milestone/131?closed=1>`__ milestone.
146 155
147 156 Thanks
148 157 ------
149 158
150 159 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
151 160 work on IPython and related libraries.
152 161
153 162
154 163 .. _version 8.23:
155 164
156 165 IPython 8.23
157 166 ============
158 167
159 168 Super tiny release of IPython on Sunday – a bit later than usual, which is also
160 169 `πŸ³οΈβ€βš§οΈ International Transgender Day of VisibilityπŸ³οΈβ€βš§οΈ
161 170 <https://en.wikipedia.org/wiki/International_Transgender_Day_of_Visibility>`_ –
162 171 so a though for you on this day, you matter and you are valid [1]_.
163 172
164 173 This is a minuscule release with only 5 Pull requests.
165 174
166 175 Main change is :ghpull:`14357` which improve inference from return type
167 176 annotations in completer and the introduction of the optional target
168 177 ``ipython[matplotlib]`` to explicitly request the matplotlib optional
169 178 dependencies.
170 179
171 180 As usual you can find the full list of PRs on GitHub under `the 8.23
172 181 <https://github.com/ipython/ipython/milestone/130?closed=1>`__ milestone.
173 182
174 183 Thanks
175 184 ------
176 185
177 186 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
178 187 work on IPython and related libraries.
179 188
180 189
181 190 .. _version 8.22:
182 191
183 192 IPython 8.22, 8.22.1 and 8.22.2
184 193 ===============================
185 194
186 195 Quick release of IPython for this short month of February, with quite a bit of
187 196 activity with more than 15 PRs.
188 197
189 198 I am not going to details all the changes, but among other we have :
190 199
191 200 - More compatibility with emscripten :ghpull:`14316`, :ghpull:`14318`,
192 201 - Test more downstream project to avoid breakage :ghpull:`14317`
193 202 - Fix recently introduced bug with the ``store`` magic.
194 203 - Fix issues with multiple call to ``matplotlib.pyplot.switch_backend``
195 204 - Fix crashing IPython when some tracebacks encounter dynamically evaluated
196 205 code.
197 206
198 207 IPython 8.22.1 increase the minimal traitlets version, and 8.22.2 fix a critical
199 208 bug on emscripten preventing to use some magics like ``%matplotlib`` on
200 209 jupyter-light.
201 210
202 211 API changes
203 212 -----------
204 213
205 214 One of the largest change is the update the mimehooks and inspector API, see
206 215 :ghpull:`14342`. It should be backward compatible, but many hooks now receive a
207 216 single object with many fields allowing us flexibility to update the API later.
208 217
209 218
210 219 Packaging changes
211 220 -----------------
212 221
213 222 Thanks to `@mkoppe <https://github.com/mkoeppe>`__, we are slowly getting rid of
214 223 setup.py finally migrating to ``pyproject.toml``. There is still quite a bit of
215 224 work, and please open an issue if you encounter any problem.
216 225
217 226
218 227 Deprecation
219 228 -----------
220 229
221 230 A number of unused functions have been marked deprecated or pending deprecation.
222 231 Please let us know if you encounter any of those deprecation messages for us to
223 232 adjust the removal timeline.
224 233
225 234
226 235 Thanks
227 236 ------
228 237
229 238 Many thanks to `@mkoppe <https://github.com/mkoeppe>`__ and `@krassowski
230 239 <https://github.com/krassowski>`__ for their multiple contributions and codebase
231 240 cleanup.
232 241
233 242 As usual you can find the full list of PRs on GitHub under `the 8.22
234 243 <https://github.com/ipython/ipython/milestone/129?closed=1>`__ milestone.
235 244
236 245 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
237 246 work on IPython and related libraries.
238 247
239 248
240 249 .. _version 8.21:
241 250
242 251 IPython 8.21
243 252 ------------
244 253
245 254 More substantial release of IPython slightly out of schedule as it was not
246 255 possible for me to make a release last Friday.
247 256
248 257 Few new features are present, but the codebase has been cleaned, and a couple
249 258 of API are _considered_ for deprecation. They are not deprecated yet, but as
250 259 they do not seem to be quite used, they may emit a warning, in which case please
251 260 comment on the relevant issue to inform me of _which_ project use those feature
252 261 and how you use them. Depending on the feedback I might change the timeline for
253 262 deprecation.
254 263
255 264 This release saw 14 PRs, with more outside contribution than usual,
256 265 I'll note in particular PRs related to making IPython work on emscripten.
257 266
258 267 I also want to point that we are _trying_ to keep compatibility with Python 3.13,
259 268 but it's a cat and mouse game. Plus I am low on time, so I would appreciate any
260 269 help with that.
261 270
262 271 Deprecations
263 272 ~~~~~~~~~~~~
264 273
265 274 - :ghpull:`14307` Pending Deprecation of
266 275 ``ColorSchemeTable.set_active_scheme(...)``'s ``case_sensitive`` Parameter.
267 276 - :ghpull:`14305` Pending Deprecation of constructing ``ColorScheme`` via
268 277 ``kwargs``, in favor passing a single dict.
269 278
270 279
271 280 Fixes
272 281 ~~~~~
273 282
274 283 - :ghpull:`14284` TerminalIPythonApp's would warn that ``auto_create`` option is not
275 284 recognized.
276 285 - :ghpull:`14286` Fix a crash with ``NotOneValueFound`` when rendering complex
277 286 tracebacks.
278 287
279 288 - :ghpull:`14287` Partial Python 3.13 compatibility
280 289 - :ghpull:`14290` Docs/Typos.
281 290
282 291 Changes
283 292 ~~~~~~~
284 293
285 294 - :ghpull:`14289` ``ipdb.set_trace()`` now accepts ``header=`` for better
286 295 compatibility with ``pdb.set_trace()``
287 296
288 297 - :ghpull:`14300` and :ghpull:`14301` Add hooking ability to produce
289 298 mimebundle.
290 299
291 300 We'll outline :ghpull:`14300`, it is now possible to extend the ``?/??``
292 301 operator to return more mimetypes to render richer help in frontends that
293 302 support it. In particular you could send a json representation of the help that
294 303 could be displayed in a customizable way.
295 304
296 305 Miscellaneous
297 306 ~~~~~~~~~~~~~
298 307
299 308 - :ghpull:`14291` Misc Refactor of Color handling
300 309 - :ghpull:`14295` Misc test skip on problematic Pypy versions.
301 310
302 311
303 312 Thanks
304 313 ~~~~~~
305 314
306 315 Special thanks to all our contributors, and to the Pypy team that was extremely
307 316 reactive in helping to investigate a fixing a rare unicode+windows bug.
308 317
309 318 As usual you can find the full list of PRs on GitHub under `the 8.21
310 319 <https://github.com/ipython/ipython/milestone/128?closed=1>`__ milestone.
311 320
312 321 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
313 322 work on IPython and related libraries.
314 323
315 324
316 325 .. _version 8.20:
317 326
318 327 IPython 8.20
319 328 ------------
320 329
321 330 Quick IPython release in this beginning of 2024, barely 2 weeks after the previous
322 331 release.
323 332
324 333 This is mostly to fix a backward compatibility issue, I would have done a patch
325 334 release earlier if I could. As a few other cleanup are also part of this
326 335 release, this will get a minor version bump.
327 336
328 337
329 338 The crux of this release is :ghpull:`14274` (Inspect continuation prompt
330 339 signature and pass only viable arguments), the rest of the changes are mostly
331 340 type annotation, and a few compatibility issues with Python 3.13 that are
332 341 getting addressed.
333 342
334 343 Python 3.13 compatibility is still not complete (help welcomed).
335 344
336 345 As usual you can find the full list of PRs on GitHub under `the 8.20
337 346 <https://github.com/ipython/ipython/milestone/127?closed=1>`__ milestone.
338 347
339 348 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
340 349 work on IPython and related libraries.
341 350
342 351
343 352 .. _version 8.19:
344 353
345 354 IPython 8.19
346 355 ------------
347 356
348 357 New release of IPython a bit before the end of the month, and end of the year.
349 358
350 359 Mostly cleanup and deprecation, due to upstream deprecation and removal.
351 360
352 361 Remove of Python 3.9 support
353 362 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354 363
355 364 A bit later than originally plan, IPython 8.19 does not support Python 3.9
356 365 anymore, as well as the few conditional code that were executing only on Python
357 366 3.9. :ghpull:`14254`
358 367
359 368 We used the opportunity to deprecate ``IPython.utils.tz`` :ghpull:`14256`, due
360 369 to upstream deprecation of some timezone utilities. It will be removed at a later
361 370 date.
362 371
363 372 We now also run CI on Python 3.12 (what I likely should have done before), but
364 373 running on too many Python version uses a lot of CI time.
365 374
366 375 Absolute and relative Line Numbers in Prompts
367 376 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 377
369 378 Thanks to the contribution of ``cohml``, IPython CLI now support absolute and
370 379 relative line numbers in both vi and emacs prompt, use for example
371 380 ``c.TerminalInteractiveShell.prompt_line_number_format='{line: 4d}/{rel_line:+03d} | '``
372 381 configuration option to display both in a custom format.
373 382
374 383 Miscellaneous
375 384 ~~~~~~~~~~~~~
376 385
377 386 In addition to various bugfixes, I unpinned pytest, let me know if there are any
378 387 issues and we'll re-pin.
379 388
380 389 See you in 2024
381 390 ~~~~~~~~~~~~~~~
382 391
383 392 As usual you can find the full list of PRs on GitHub under `the 8.19
384 393 <https://github.com/ipython/ipython/milestone/126?closed=1>`__ milestone.
385 394
386 395 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
387 396 work on IPython and related libraries.
388 397
389 398 .. _version 8.18:
390 399
391 400 IPython 8.18 and 8.18.1
392 401 -----------------------
393 402
394 403 8.18.1 is identical to 8.18 but pin ``prompt_toolkit`` to greater than ``3.0.41``
395 404
396 405 Small release of IPython that fixes a small number of inconveniences.
397 406
398 407 - :ghpull:`14251` Fix a memory leak in qt event loop integration by setting
399 408 the Loop parent to None.
400 409 - :ghpull:`14252` Pickleshare was made an optional dependency in 8.17, this
401 410 leads to warnings in some installations when using modules completions. The
402 411 warning has been silenced.
403 412 - :ghpull:`14241` Update event loop code for compatibility with more recent
404 413 ``prompt_toolkit`` due to deprecations in Python 3.12.
405 414 - :ghpull:`14245` Fix doc example on Pygments styles
406 415 - :ghpull:`14238` Remove dependency on app_nope, this is actually only a
407 416 dependency of IPykernel.
408 417
409 418 As usual you can find the full list of PRs on GitHub under `the 8.18
410 419 <https://github.com/ipython/ipython/milestone/125?closed=1>`__ milestone.
411 420
412 421 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
413 422 work on IPython and related libraries.
414 423
415 424 .. _version 8.17.1:
416 425 .. _version 8.17:
417 426
418 427 IPython 8.17, 8.17.1
419 428 --------------------
420 429
421 430 Medium-sized release of IPython that includes some cleanup (backcall, python2 leftovers)
422 431 and some refactoring improvements (typing, pathlib) and a fix on completion.
423 432
424 433 - :ghpull:`14216` remove backcall dependency
425 434 - :ghpull:`14217` make pickleshare dependency optional
426 435 - :ghpull:`14185` support completion based on type annotations of calls
427 436
428 437 Reverted in 8.17.1:
429 438
430 439 - :ghpull:`14190` remove support for python 2 in lexers (reverted in 8.17.1 as it is imported by qtconsole/spyder)
431 440
432 441
433 442 Mamba and Micromamba magic commands
434 443 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
435 444
436 445 In addition to the ``%conda`` magic command for calling ``conda`` in IPython,
437 446 the ``%mamba`` and ``%micromamba`` magic commands now
438 447 call ``mamba`` and ``micromamba`` if they are on ``sys.path``.
439 448
440 449 .. code::
441 450
442 451 %mamba install pkgname
443 452 %micromamba install pkgname
444 453 %conda install pkgname
445 454 %pip install pkgname
446 455
447 456 %mamba --help
448 457 %micromamba --help
449 458 %conda --help
450 459 %pip --help # works w/ JupyterLite
451 460 !pip --help
452 461
453 462
454 463 :ghpull:`14191`
455 464
456 465 ----
457 466
458 467 As usual you can find the full list of PRs on GitHub under `the 8.17
459 468 <https://github.com/ipython/ipython/milestone/123?closed=1>`__ milestone.
460 469
461 470 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
462 471 work on IPython and related libraries.
463 472
464 473 .. _version 8.16:
465 474 .. _version 8.16.1:
466 475
467 476 IPython 8.16, 8.16.1
468 477 --------------------
469 478
470 479 Small double release of IPython (with the 8.12.3 release notes just below).
471 480 Mostly bug fixes and cleanups, and type annotations. Of interest for users:
472 481
473 482 - :ghpull:`14153` Fix a bug of the new iPdb chained traceback where some
474 483 Exception would not have any traceback. (see upstream fix in CPython for more
475 484 details).
476 485 - :ghpull:`14168` Fix case with spurious message about event loops when using
477 486 matplotlib.
478 487
479 488 This PR is in 8.16.0 but reverted in 8.16.1, we'll rework the fix for 8.17
480 489
481 490 - :ghpull:`14163` Fix an error where semicolon would not suppress output.
482 491
483 492 As usual you can find the full list of PRs on GitHub under `the 8.16
484 493 <https://github.com/ipython/ipython/milestone/121?closed=1>`__ and `8.16.1 milestone
485 494 <https://github.com/ipython/ipython/milestone/124?closed=1>`__.
486 495
487 496 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
488 497 work on IPython and related libraries.
489 498
490 499 .. _version 8.12.3:
491 500
492 501 IPython 8.12.3
493 502 --------------
494 503
495 504 Tiny release of 8.12.3 that backport a small number of fixes for users still
496 505 using Python 3.8.
497 506
498 507 - :ghpull:`14080` add passthrough filter shortcuts
499 508 - :ghpull:`14169` Fix `InteractiveShellEmbed`
500 509
501 510 .. _version 8.15:
502 511
503 512 IPython 8.15
504 513 ------------
505 514
506 515 Medium release of IPython after a couple of month hiatus, and a bit
507 516 off-schedule.
508 517
509 518 Among other, IPython 8.15:
510 519
511 520 - Improve compatibility with future version of Python 3.12/3.13
512 521 :ghpull:`14107`, :ghpull:`14139`,
513 522 - Improve support for ``ExceptionGroups``, :ghpull:`14108`
514 523 - Fix hangs in ``%gui osx``, :ghpull:`14125`
515 524 - Fix memory lead with ``%reset``, :ghpull:`14133`
516 525 - Unstable config option to modify traceback highlighting that is sometime hard
517 526 to read :ghpull:`14138`
518 527 - Support ``.`` in ``ipdb`` as an argument to the ``list`` command
519 528 :ghpull:`14121`
520 529 - Workroud ``parso`` showing warning message when the default logger level is
521 530 changed :ghpull:`14119`
522 531 - Fix multiple issues with matplotlib interactive mode, qt5/qt6 :ghpull:`14128`
523 532
524 533 Support for PEP-678 Exception Notes
525 534 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
526 535
527 536 Ultratb now shows :pep:`678` notes, improving your debugging experience on
528 537 Python 3.11+ or with libraries such as Pytest and Hypothesis.
529 538
530 539 Native fallback for displaying ExceptionGroup
531 540 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
532 541 ExceptionGroups are now displayed with ``traceback.print_exc``, as a temporary fix until UltraTB properly supports displaying child exceptions.
533 542
534 543
535 544 We have two larger features:
536 545
537 546 AST-based macros
538 547 ~~~~~~~~~~~~~~~~
539 548
540 549 :ghpull:`14100` introduce a new and efficient way to modify each execution block
541 550 (cell) using an template-ast-based transform. Unlike IPython pre and post code
542 551 execution hooks, this actually transform the code that is execute with as
543 552 minimal as possible overhead. While it was already technically possible to
544 553 register ast transformers for IPython this was far from evident.
545 554
546 555 This should make it trivial to hook into IPython to implement custom hooks, that
547 556 for example time or profile your code, catch exceptions to provide error
548 557 messages for students or do any other kind of transformations.
549 558
550 559 In addition to programmatic API there is also a magic to quickly register
551 560 hooks::
552 561
553 562 In [1]: %%code_wrap before_after
554 563 ...: print('before')
555 564 ...: __code__
556 565 ...: print('after')
557 566 ...: __ret__
558 567
559 568 This mean that for any subsequent execution code will be executed.
560 569 You can modify the above to print the date, compute the execution time,
561 570 retry the code in a for loop....
562 571
563 572
564 573 Allow IPdb/Pdb to move between chained exceptions
565 574 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
566 575
567 576 The main change is the addition of the ability to move between chained
568 577 exceptions when using IPdb, this feature was also contributed to upstream Pdb
569 578 and is thus native to CPython in Python 3.13+ Though ipdb should support this
570 579 feature in older version of Python. I invite you to look at the `CPython changes
571 580 and docs <https://github.com/python/cpython/pull/106676>`__ for more details.
572 581
573 582 In short, once in post-mortem debugger (``%debug``), you can use the ipdb
574 583 ``exceptions`` command to switch exceptions, for example:
575 584
576 585 .. code-block:: ipython
577 586
578 587 In [1]: def foo(x):
579 588 ...: try:
580 589 ...: bar(x)
581 590 ...: except Exception as e:
582 591 ...: raise ValueError("foo (): bar failed") from e
583 592 ...:
584 593 ...: def bar(x):
585 594 ...: 1 / X
586 595 ...:
587 596
588 597 In [2]: foo(0)
589 598 ---------------------------------------------------------------------------
590 599 NameError Traceback (most recent call last)
591 600 Cell In[1], line 3, in foo(x)
592 601 2 try:
593 602 ----> 3 bar(x)
594 603 4 except Exception as e:
595 604
596 605 Cell In[1], line 9, in bar(x)
597 606 8 def bar(x):
598 607 ----> 9 1 / X
599 608
600 609 NameError: name 'X' is not defined
601 610
602 611 The above exception was the direct cause of the following exception:
603 612
604 613 ValueError Traceback (most recent call last)
605 614 Cell In[2], line 1
606 615 ----> 1 foo(0)
607 616
608 617 Cell In[1], line 5, in foo(x)
609 618 3 bar(x)
610 619 4 except Exception as e:
611 620 ----> 5 raise ValueError("foo (): bar failed") from e
612 621
613 622 ValueError: foo (): bar failed
614 623
615 624 In [3]: %debug
616 625 > <ipython-input-1-b0bbdc271ffb>(5)foo()
617 626 3 bar(x)
618 627 4 except Exception as e:
619 628 ----> 5 raise ValueError("foo (): bar failed") from e
620 629
621 630 In previous ipdb you could not go into the bar error, now from within pdb you
622 631 can use ``exceptions``:
623 632
624 633 .. code-block:: ipython
625 634
626 635 ipdb> exceptions
627 636 0 NameError("name 'X' is not defined")
628 637 > 1 ValueError('foo (): bar failed')
629 638
630 639 ipdb> exceptions 0
631 640 > <ipython-input-1-b0bbdc271ffb>(9)bar()
632 641 6
633 642 7
634 643 8 def bar(x):
635 644 ----> 9 1 / X
636 645 10
637 646
638 647 ipdb>
639 648
640 649 In particular I want to thank the `D.E. Shaw group <https://www.deshaw.com/>`__
641 650 for suggesting and funding the two largest feature as well as many bug fixes of
642 651 this release.
643 652
644 653 As usual you can find the full list of PRs on GitHub under `the 8.15 milestone
645 654 <https://github.com/ipython/ipython/milestone/120?closed=1>`__.
646 655
647 656
648 657
649 658 .. _version 8.14:
650 659
651 660 IPython 8.14
652 661 ------------
653 662
654 663 Small release of IPython.
655 664
656 665 - :ghpull:`14080` fixes some shortcuts issues.
657 666 - :ghpull:`14056` Add option to ``%autoreload`` to hide errors when reloading code. This will be the default for spyder
658 667 user is my understanding.
659 668 - :ghpull:`14039` (and :ghpull:`14040`) to show exception notes in tracebacks.
660 669
661 670 - :ghpull:`14076` Add option to EventManager to prevent printing
662 671
663 672
664 673 SPEC 0 and SPEC 4
665 674 ~~~~~~~~~~~~~~~~~
666 675
667 676 You've heard about the NEPs, (NumPy enhancement Proposal), having a NEP for something non-numpy specific was sometime confusing.
668 677 Long live the `SPECs <https://scientific-python.org/specs/>`_.
669 678
670 679 We are now trying to follow SPEC 0 (aka old NEP 29) for support of upstream libraries.
671 680
672 681 We also now try to follow SPEC 4 (test and publish nightly on a centralized nightly repository).
673 682 We encourage you to do so as well in order to report breakage, and contribute to the SPEC process !
674 683
675 684
676 685 Python 3.12 compatibility ?
677 686 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
678 687
679 688 Python 3.12 changed its tokenizer to have better support for f-strings and allow arbitrary expression.
680 689 This is a great new feature and performance improvement in Python 3.12.
681 690
682 691 Unfortunately this means the new tokenizer does not support incomplete or invalid Python which will
683 692 break many features of IPython. Thus compatibility of IPython with Python 3.12 is not guaranteed.
684 693 It is unclear to which extent IPython is affected, and whether we can/should try to still support magics, shell
685 694 escape (``! ....``), ..., as well as how to do it if we can.
686 695
687 696 In addition even if we there is technical feasibility to do so, it is no clear we have the resources to do it.
688 697 We are thus looking for your help if you can _test_ on Python 3.12 to see to which extent this affects users and which
689 698 features are critical.
690 699
691 700 We are not going to pin IPython to Python ``<3.12`` as otherwise on install pip would downgrade/resolve to IPython 8.13,
692 701 so if you plan to update to Python 3.12 after its release, we encourage for extra care.
693 702
694 703
695 704 .. _version 8.13.1:
696 705 .. _version 8.13.2:
697 706 .. _version 8.12.2:
698 707
699 708 IPython 8.13.1, 8.13.2 and 8.12.2
700 709 ---------------------------------
701 710
702 711 3 quick in succession patch release of IPython in addition to IPython 8.13.0
703 712 having been yanked.
704 713
705 714 IPython 8.13.0 was improperly tagged as still compatible with Python 3.8, and
706 715 still had some mention of compatibility with 3.8. IPython 8.13.1 is identical to
707 716 8.13 but with the exception of being correctly tagged. This release and yank was
708 717 mostly done to fix CI.
709 718
710 719 IPython 8.12.2 and 8.13.2 contain UI fixes, with respect to right arrow not
711 720 working in some case in the terminal, and 8.12.2 contain also a requested
712 721 backport of :ghpull:`14029` (Allow safe access to the ``__getattribute__``
713 722 method of modules) for tab completion.
714 723
715 724 .. _version 8.13:
716 725
717 726 IPython 8.13
718 727 ------------
719 728
720 729 As usual for the end of the month, minor release of IPython. This release is
721 730 significant in that it not only has a number of bugfixes, but also drop support
722 731 for Python 3.8 as per NEP 29 (:ghpull:`14023`).
723 732
724 733 All the critical bugfixes have been backported onto the 8.12.1 release (see
725 734 below). In addition to that went into 8.12.1 you'll find:
726 735
727 736 - Pretty representation for ``Counter`` has been fixed to match the Python one
728 737 and be in decreasing order. :ghpull:`14032`
729 738 - Module completion is better when jedi is disabled :ghpull:`14029`.
730 739 - Improvement of ``%%bash`` magic that would get stuck :ghpull:`14019`
731 740
732 741
733 742 We hope you enjoy this release an will maybe see you at JupyterCon in less than
734 743 two weeks.
735 744
736 745 As usual you can find the full list of PRs on GitHub under `the 8.13 milestone
737 746 <https://github.com/ipython/ipython/milestone/115?closed=1>`__.
738 747
739 748 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
740 749 work on IPython and related libraries.
741 750
742 751
743 752 .. _version 8.12.1:
744 753
745 754 IPython 8.12.1
746 755 --------------
747 756
748 757 This is the twin release of IPython 8.13 that contain only critical UI and bug
749 758 fixes. The next minor version of IPython has dropped support for Python 3.8 – as
750 759 per Nep 29 and this IPython 8.12.x will now only receive bugfixes.
751 760
752 761
753 762 - :ghpull:`14004` Fix a bug introduced in IPython 8.12 that crash when
754 763 inspecting some docstrings.
755 764 - :ghpull:`14010` Fix fast traceback code that was not working in some case.
756 765 - :ghpull:`14014` Fix ``%page`` magic broken in some case.
757 766 - :ghpull:`14026`, :ghpull:`14027` Tweak default shortcut with respect to
758 767 autosuggestions.
759 768 - :ghpull:`14033` add back the ability to use ``.get()`` on OInfo object for
760 769 backward compatibility with h5py (this will be re-deprecated later, and h5py
761 770 will also get a fix).
762 771
763 772 As usual you can find the full list of PRs on GitHub under `the 8.12.1 milestone
764 773 <https://github.com/ipython/ipython/milestone/116?closed=1>`__.
765 774
766 775 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
767 776 work on IPython and related libraries.
768 777
769 778 .. _version 8.12.0:
770 779
771 780 IPython 8.12
772 781 ------------
773 782
774 783 Hopefully slightly early release for IPython 8.12. Last Thursday of the month,
775 784 even if I guess it's likely already Friday somewhere in the pacific ocean.
776 785
777 786 A number of PRs and bug fixes this month with close to 20 PRs merged !
778 787
779 788
780 789 The IPython repo reached :ghpull:`14000` !! Actually the PR that create those exact release
781 790 note is :ghpull:`14000`. Ok, more issues and PR is not always better, and I'd
782 791 love to have more time to close issues and Pull Requests.
783 792
784 793 Let's note that in less than 2 month JupyterCon is back, in Paris please visit
785 794 `jupytercon.com <https://jupytercon.com>`__, and looking forward to see you
786 795 there.
787 796
788 797 Packagers should take note that ``typing_extension`` is now a mandatory dependency
789 798 for Python versions ``<3.10``.
790 799
791 800
792 801
793 802 Let's note also that according to `NEP29
794 803 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`__, It is soon time to
795 804 stop support for Python 3.8 that will be release more than 3 and 1/2 years ago::
796 805
797 806 On Apr 14, 2023 drop support for Python 3.8 (initially released on Oct 14, 2019)
798 807
799 808 Thus I am likely to stop advertising support for Python 3.8 in the next
800 809 release at the end of April.
801 810
802 811
803 812 Here are some miscellaneous updates of interest:
804 813
805 814 - :ghpull:`13957` brings updates to the Qt integration, particularly for Qt6.
806 815 - :ghpull:`13960` fixes the %debug magic command to give access to the local
807 816 scope.
808 817 - :ghpull:`13964` fixes some crashes with the new fast traceback code. Note that
809 818 there are still some issues with the fast traceback code, and I a, likely
810 819 to fix and tweak behavior.
811 820 - :ghpull:`13973` We are slowly migrating IPython internals to use proper type
812 821 objects/dataclasses instead of dictionaries to allow static typing checks.
813 822 These are technically public API and could lead to breakage, so please let us
814 823 know if that's the case and I'll mitigate.
815 824 - :ghpull:`13990`, :ghpull:`13991`, :ghpull:`13994` all improve keybinding and
816 825 shortcut configurability.
817 826
818 827 As usual you can find the full list of PRs on GitHub under `the 8.12 milestone
819 828 <https://github.com/ipython/ipython/milestone/114?closed=1>`__.
820 829
821 830 We want to thank the D.E. Shaw group for requesting and sponsoring the work on
822 831 the following big feature. We had productive discussions on how to best expose
823 832 this feature
824 833
825 834 Dynamic documentation dispatch
826 835 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
827 836
828 837 We are experimenting with dynamic documentation dispatch for object attribute.
829 838 See :ghissue:`13860`. The goal is to allow object to define documentation for
830 839 their attributes, properties, even when those are dynamically defined with
831 840 `__getattr__`.
832 841
833 842 In particular when those objects are base types it can be useful to show the
834 843 documentation
835 844
836 845
837 846 .. code-block:: ipython
838 847
839 848
840 849 In [1]: class User:
841 850 ...:
842 851 ...: __custom_documentations__ = {
843 852 ...: "first": "The first name of the user.",
844 853 ...: "last": "The last name of the user.",
845 854 ...: }
846 855 ...:
847 856 ...: first:str
848 857 ...: last:str
849 858 ...:
850 859 ...: def __init__(self, first, last):
851 860 ...: self.first = first
852 861 ...: self.last = last
853 862 ...:
854 863 ...: @property
855 864 ...: def full(self):
856 865 ...: """`self.first` and `self.last` joined by a space."""
857 866 ...: return self.first + " " + self.last
858 867 ...:
859 868 ...:
860 869 ...: user = Person('Jane', 'Doe')
861 870
862 871 In [2]: user.first?
863 872 Type: str
864 873 String form: Jane
865 874 Length: 4
866 875 Docstring: the first name of a the person object, a str
867 876 Class docstring:
868 877 ....
869 878
870 879 In [3]: user.last?
871 880 Type: str
872 881 String form: Doe
873 882 Length: 3
874 883 Docstring: the last name, also a str
875 884 ...
876 885
877 886
878 887 We can see here the symmetry with IPython looking for the docstring on the
879 888 properties:
880 889
881 890 .. code-block:: ipython
882 891
883 892
884 893 In [4]: user.full?
885 894 HERE
886 895 Type: property
887 896 String form: <property object at 0x102bb15d0>
888 897 Docstring: first and last join by a space
889 898
890 899
891 900 Note that while in the above example we use a static dictionary, libraries may
892 901 decide to use a custom object that define ``__getitem__``, we caution against
893 902 using objects that would trigger computation to show documentation, but it is
894 903 sometime preferable for highly dynamic code that for example export ans API as
895 904 object.
896 905
897 906
898 907
899 908 .. _version 8.11.0:
900 909
901 910 IPython 8.11
902 911 ------------
903 912
904 913 Back on almost regular monthly schedule for IPython with end-of-month
905 914 really-late-Friday release to make sure some bugs are properly fixed.
906 915 Small addition of with a few new features, bugfix and UX improvements.
907 916
908 917 This is a non-exhaustive list, but among other you will find:
909 918
910 919 Faster Traceback Highlighting
911 920 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
912 921
913 922 Resurrection of pre-IPython-8 traceback highlighting code.
914 923
915 924 Really long and complicated files were slow to highlight in traceback with
916 925 IPython 8 despite upstream improvement that make many case better. Therefore
917 926 starting with IPython 8.11 when one of the highlighted file is more than 10 000
918 927 line long by default, we'll fallback to a faster path that does not have all the
919 928 features of highlighting failing AST nodes.
920 929
921 930 This can be configures by setting the value of
922 931 ``IPython.code.ultratb.FAST_THRESHOLD`` to an arbitrary low or large value.
923 932
924 933
925 934 Autoreload verbosity
926 935 ~~~~~~~~~~~~~~~~~~~~
927 936
928 937 We introduce more descriptive names for the ``%autoreload`` parameter:
929 938
930 939 - ``%autoreload now`` (also ``%autoreload``) - perform autoreload immediately.
931 940 - ``%autoreload off`` (also ``%autoreload 0``) - turn off autoreload.
932 941 - ``%autoreload explicit`` (also ``%autoreload 1``) - turn on autoreload only for modules
933 942 whitelisted by ``%aimport`` statements.
934 943 - ``%autoreload all`` (also ``%autoreload 2``) - turn on autoreload for all modules except those
935 944 blacklisted by ``%aimport`` statements.
936 945 - ``%autoreload complete`` (also ``%autoreload 3``) - all the features of ``all`` but also adding new
937 946 objects from the imported modules (see
938 947 IPython/extensions/tests/test_autoreload.py::test_autoload_newly_added_objects).
939 948
940 949 The original designations (e.g. "2") still work, and these new ones are case-insensitive.
941 950
942 951 Additionally, the option ``--print`` or ``-p`` can be added to the line to print the names of
943 952 modules being reloaded. Similarly, ``--log`` or ``-l`` will output the names to the logger at INFO
944 953 level. Both can be used simultaneously.
945 954
946 955 The parsing logic for ``%aimport`` is now improved such that modules can be whitelisted and
947 956 blacklisted in the same line, e.g. it's now possible to call ``%aimport os, -math`` to include
948 957 ``os`` for ``%autoreload explicit`` and exclude ``math`` for modes ``all`` and ``complete``.
949 958
950 959 Terminal shortcuts customization
951 960 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
952 961
953 962 Previously modifying shortcuts was only possible by hooking into startup files
954 963 and practically limited to adding new shortcuts or removing all shortcuts bound
955 964 to a specific key. This release enables users to override existing terminal
956 965 shortcuts, disable them or add new keybindings.
957 966
958 967 For example, to set the :kbd:`right` to accept a single character of auto-suggestion
959 968 you could use::
960 969
961 970 my_shortcuts = [
962 971 {
963 972 "command": "IPython:auto_suggest.accept_character",
964 973 "new_keys": ["right"]
965 974 }
966 975 ]
967 976 %config TerminalInteractiveShell.shortcuts = my_shortcuts
968 977
969 978 You can learn more in :std:configtrait:`TerminalInteractiveShell.shortcuts`
970 979 configuration reference.
971 980
972 981 Miscellaneous
973 982 ~~~~~~~~~~~~~
974 983
975 984 - ``%gui`` should now support PySide6. :ghpull:`13864`
976 985 - Cli shortcuts can now be configured :ghpull:`13928`, see above.
977 986 (note that there might be an issue with prompt_toolkit 3.0.37 and shortcut configuration).
978 987
979 988 - Capture output should now respect ``;`` semicolon to suppress output.
980 989 :ghpull:`13940`
981 990 - Base64 encoded images (in jupyter frontend), will not have trailing newlines.
982 991 :ghpull:`13941`
983 992
984 993 As usual you can find the full list of PRs on GitHub under `the 8.11 milestone
985 994 <https://github.com/ipython/ipython/milestone/113?closed=1>`__.
986 995
987 996 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
988 997 work on IPython and related libraries.
989 998
990 999 .. _version 8.10.0:
991 1000
992 1001 IPython 8.10
993 1002 ------------
994 1003
995 1004 Out of schedule release of IPython with minor fixes to patch a potential CVE-2023-24816.
996 1005 This is a really low severity CVE that you most likely are not affected by unless:
997 1006
998 1007 - You are on windows.
999 1008 - You have a custom build of Python without ``_ctypes``
1000 1009 - You cd or start IPython or Jupyter in untrusted directory which names may be
1001 1010 valid shell commands.
1002 1011
1003 1012 You can read more on `the advisory
1004 1013 <https://github.com/ipython/ipython/security/advisories/GHSA-29gw-9793-fvw7>`__.
1005 1014
1006 1015 In addition to fixing this CVE we also fix a couple of outstanding bugs and issues.
1007 1016
1008 1017 As usual you can find the full list of PRs on GitHub under `the 8.10 milestone
1009 1018 <https://github.com/ipython/ipython/milestone/112?closed=1>`__.
1010 1019
1011 1020 In Particular:
1012 1021
1013 1022 - bump minimum numpy to `>=1.21` version following NEP29. :ghpull:`13930`
1014 1023 - fix for compatibility with MyPy 1.0. :ghpull:`13933`
1015 1024 - fix nbgrader stalling when IPython's ``showtraceback`` function is
1016 1025 monkeypatched. :ghpull:`13934`
1017 1026
1018 1027
1019 1028
1020 1029 As this release also contains those minimal changes in addition to fixing the
1021 1030 CVE I decided to bump the minor version anyway.
1022 1031
1023 1032 This will not affect the normal release schedule, so IPython 8.11 is due in
1024 1033 about 2 weeks.
1025 1034
1026 1035 .. _version 8.9.0:
1027 1036
1028 1037 IPython 8.9.0
1029 1038 -------------
1030 1039
1031 1040 Second release of IPython in 2023, last Friday of the month, we are back on
1032 1041 track. This is a small release with a few bug-fixes, and improvements, mostly
1033 1042 with respect to terminal shortcuts.
1034 1043
1035 1044
1036 1045 The biggest improvement for 8.9 is a drastic amelioration of the
1037 1046 auto-suggestions sponsored by D.E. Shaw and implemented by the more and more
1038 1047 active contributor `@krassowski <https://github.com/krassowski>`.
1039 1048
1040 1049 - ``right`` accepts a single character from suggestion
1041 1050 - ``ctrl+right`` accepts a semantic token (macos default shortcuts take
1042 1051 precedence and need to be disabled to make this work)
1043 1052 - ``backspace`` deletes a character and resumes hinting autosuggestions
1044 1053 - ``ctrl-left`` accepts suggestion and moves cursor left one character.
1045 1054 - ``backspace`` deletes a character and resumes hinting autosuggestions
1046 1055 - ``down`` moves to suggestion to later in history when no lines are present below the cursors.
1047 1056 - ``up`` moves to suggestion from earlier in history when no lines are present above the cursor.
1048 1057
1049 1058 This is best described by the Gif posted by `@krassowski
1050 1059 <https://github.com/krassowski>`, and in the PR itself :ghpull:`13888`.
1051 1060
1052 1061 .. image:: ../_images/autosuggest.gif
1053 1062
1054 1063 Please report any feedback in order for us to improve the user experience.
1055 1064 In particular we are also working on making the shortcuts configurable.
1056 1065
1057 1066 If you are interested in better terminal shortcuts, I also invite you to
1058 1067 participate in issue `13879
1059 1068 <https://github.com/ipython/ipython/issues/13879>`__.
1060 1069
1061 1070
1062 1071 As we follow `NEP29
1063 1072 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`__, next version of
1064 1073 IPython will officially stop supporting numpy 1.20, and will stop supporting
1065 1074 Python 3.8 after April release.
1066 1075
1067 1076 As usual you can find the full list of PRs on GitHub under `the 8.9 milestone
1068 1077 <https://github.com/ipython/ipython/milestone/111?closed=1>`__.
1069 1078
1070 1079
1071 1080 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1072 1081 work on IPython and related libraries.
1073 1082
1074 1083 .. _version 8.8.0:
1075 1084
1076 1085 IPython 8.8.0
1077 1086 -------------
1078 1087
1079 1088 First release of IPython in 2023 as there was no release at the end of
1080 1089 December.
1081 1090
1082 1091 This is an unusually big release (relatively speaking) with more than 15 Pull
1083 1092 Requests merged.
1084 1093
1085 1094 Of particular interest are:
1086 1095
1087 1096 - :ghpull:`13852` that replaces the greedy completer and improves
1088 1097 completion, in particular for dictionary keys.
1089 1098 - :ghpull:`13858` that adds ``py.typed`` to ``setup.cfg`` to make sure it is
1090 1099 bundled in wheels.
1091 1100 - :ghpull:`13869` that implements tab completions for IPython options in the
1092 1101 shell when using `argcomplete <https://github.com/kislyuk/argcomplete>`. I
1093 1102 believe this also needs a recent version of Traitlets.
1094 1103 - :ghpull:`13865` makes the ``inspector`` class of `InteractiveShell`
1095 1104 configurable.
1096 1105 - :ghpull:`13880` that removes minor-version entrypoints as the minor version
1097 1106 entry points that would be included in the wheel would be the one of the
1098 1107 Python version that was used to build the ``whl`` file.
1099 1108
1100 1109 In no particular order, the rest of the changes update the test suite to be
1101 1110 compatible with Pygments 2.14, various docfixes, testing on more recent python
1102 1111 versions and various updates.
1103 1112
1104 1113 As usual you can find the full list of PRs on GitHub under `the 8.8 milestone
1105 1114 <https://github.com/ipython/ipython/milestone/110>`__.
1106 1115
1107 1116 Many thanks to @krassowski for the many PRs and @jasongrout for reviewing and
1108 1117 merging contributions.
1109 1118
1110 1119 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1111 1120 work on IPython and related libraries.
1112 1121
1113 1122 .. _version 8.7.0:
1114 1123
1115 1124 IPython 8.7.0
1116 1125 -------------
1117 1126
1118 1127
1119 1128 Small release of IPython with a couple of bug fixes and new features for this
1120 1129 month. Next month is the end of year, it is unclear if there will be a release
1121 1130 close to the new year's eve, or if the next release will be at the end of January.
1122 1131
1123 1132 Here are a few of the relevant fixes,
1124 1133 as usual you can find the full list of PRs on GitHub under `the 8.7 milestone
1125 1134 <https://github.com/ipython/ipython/pulls?q=milestone%3A8.7>`__.
1126 1135
1127 1136
1128 1137 - :ghpull:`13834` bump the minimum prompt toolkit to 3.0.11.
1129 1138 - IPython shipped with the ``py.typed`` marker now, and we are progressively
1130 1139 adding more types. :ghpull:`13831`
1131 1140 - :ghpull:`13817` add configuration of code blacks formatting.
1132 1141
1133 1142
1134 1143 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1135 1144 work on IPython and related libraries.
1136 1145
1137 1146
1138 1147 .. _version 8.6.0:
1139 1148
1140 1149 IPython 8.6.0
1141 1150 -------------
1142 1151
1143 1152 Back to a more regular release schedule (at least I try), as Friday is
1144 1153 already over by more than 24h hours. This is a slightly bigger release with a
1145 1154 few new features that contain no less than 25 PRs.
1146 1155
1147 1156 We'll notably found a couple of non negligible changes:
1148 1157
1149 1158 The ``install_ext`` and related functions have been removed after being
1150 1159 deprecated for years. You can use pip to install extensions. ``pip`` did not
1151 1160 exist when ``install_ext`` was introduced. You can still load local extensions
1152 1161 without installing them. Just set your ``sys.path`` for example. :ghpull:`13744`
1153 1162
1154 1163 IPython now has extra entry points that use the major *and minor* version of
1155 1164 python. For some of you this means that you can do a quick ``ipython3.10`` to
1156 1165 launch IPython from the Python 3.10 interpreter, while still using Python 3.11
1157 1166 as your main Python. :ghpull:`13743`
1158 1167
1159 1168 The completer matcher API has been improved. See :ghpull:`13745`. This should
1160 1169 improve the type inference and improve dict keys completions in many use case.
1161 1170 Thanks ``@krassowski`` for all the work, and the D.E. Shaw group for sponsoring
1162 1171 it.
1163 1172
1164 1173 The color of error nodes in tracebacks can now be customized. See
1165 1174 :ghpull:`13756`. This is a private attribute until someone finds the time to
1166 1175 properly add a configuration option. Note that with Python 3.11 that also shows
1167 1176 the relevant nodes in traceback, it would be good to leverage this information
1168 1177 (plus the "did you mean" info added on attribute errors). But that's likely work
1169 1178 I won't have time to do before long, so contributions welcome.
1170 1179
1171 1180 As we follow NEP 29, we removed support for numpy 1.19 :ghpull:`13760`.
1172 1181
1173 1182
1174 1183 The ``open()`` function present in the user namespace by default will now refuse
1175 1184 to open the file descriptors 0,1,2 (stdin, out, err), to avoid crashing IPython.
1176 1185 This mostly occurs in teaching context when incorrect values get passed around.
1177 1186
1178 1187
1179 1188 The ``?``, ``??``, and corresponding ``pinfo``, ``pinfo2`` magics can now find
1180 1189 objects inside arrays. That is to say, the following now works::
1181 1190
1182 1191
1183 1192 >>> def my_func(*arg, **kwargs):pass
1184 1193 >>> container = [my_func]
1185 1194 >>> container[0]?
1186 1195
1187 1196
1188 1197 If ``container`` define a custom ``getitem``, this __will__ trigger the custom
1189 1198 method. So don't put side effects in your ``getitems``. Thanks to the D.E. Shaw
1190 1199 group for the request and sponsoring the work.
1191 1200
1192 1201
1193 1202 As usual you can find the full list of PRs on GitHub under `the 8.6 milestone
1194 1203 <https://github.com/ipython/ipython/pulls?q=milestone%3A8.6>`__.
1195 1204
1196 1205 Thanks to all hacktoberfest contributors, please contribute to
1197 1206 `closember.org <https://closember.org/>`__.
1198 1207
1199 1208 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1200 1209 work on IPython and related libraries.
1201 1210
1202 1211 .. _version 8.5.0:
1203 1212
1204 1213 IPython 8.5.0
1205 1214 -------------
1206 1215
1207 1216 First release since a couple of month due to various reasons and timing preventing
1208 1217 me for sticking to the usual monthly release the last Friday of each month. This
1209 1218 is of non negligible size as it has more than two dozen PRs with various fixes
1210 1219 an bug fixes.
1211 1220
1212 1221 Many thanks to everybody who contributed PRs for your patience in review and
1213 1222 merges.
1214 1223
1215 1224 Here is a non-exhaustive list of changes that have been implemented for IPython
1216 1225 8.5.0. As usual you can find the full list of issues and PRs tagged with `the
1217 1226 8.5 milestone
1218 1227 <https://github.com/ipython/ipython/pulls?q=is%3Aclosed+milestone%3A8.5+>`__.
1219 1228
1220 1229 - Added a shortcut for accepting auto suggestion. The End key shortcut for
1221 1230 accepting auto-suggestion This binding works in Vi mode too, provided
1222 1231 ``TerminalInteractiveShell.emacs_bindings_in_vi_insert_mode`` is set to be
1223 1232 ``True`` :ghpull:`13566`.
1224 1233
1225 1234 - No popup in window for latex generation when generating latex (e.g. via
1226 1235 `_latex_repr_`) no popup window is shows under Windows. :ghpull:`13679`
1227 1236
1228 1237 - Fixed error raised when attempting to tab-complete an input string with
1229 1238 consecutive periods or forward slashes (such as "file:///var/log/...").
1230 1239 :ghpull:`13675`
1231 1240
1232 1241 - Relative filenames in Latex rendering :
1233 1242 The `latex_to_png_dvipng` command internally generates input and output file
1234 1243 arguments to `latex` and `dvipis`. These arguments are now generated as
1235 1244 relative files to the current working directory instead of absolute file
1236 1245 paths. This solves a problem where the current working directory contains
1237 1246 characters that are not handled properly by `latex` and `dvips`. There are
1238 1247 no changes to the user API. :ghpull:`13680`
1239 1248
1240 1249 - Stripping decorators bug: Fixed bug which meant that ipython code blocks in
1241 1250 restructured text documents executed with the ipython-sphinx extension
1242 1251 skipped any lines of code containing python decorators. :ghpull:`13612`
1243 1252
1244 1253 - Allow some modules with frozen dataclasses to be reloaded. :ghpull:`13732`
1245 1254 - Fix paste magic on wayland. :ghpull:`13671`
1246 1255 - show maxlen in deque's repr. :ghpull:`13648`
1247 1256
1248 1257 Restore line numbers for Input
1249 1258 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1250 1259
1251 1260 Line number information in tracebacks from input are restored.
1252 1261 Line numbers from input were removed during the transition to v8 enhanced traceback reporting.
1253 1262
1254 1263 So, instead of::
1255 1264
1256 1265 ---------------------------------------------------------------------------
1257 1266 ZeroDivisionError Traceback (most recent call last)
1258 1267 Input In [3], in <cell line: 1>()
1259 1268 ----> 1 myfunc(2)
1260 1269
1261 1270 Input In [2], in myfunc(z)
1262 1271 1 def myfunc(z):
1263 1272 ----> 2 foo.boo(z-1)
1264 1273
1265 1274 File ~/code/python/ipython/foo.py:3, in boo(x)
1266 1275 2 def boo(x):
1267 1276 ----> 3 return 1/(1-x)
1268 1277
1269 1278 ZeroDivisionError: division by zero
1270 1279
1271 1280 The error traceback now looks like::
1272 1281
1273 1282 ---------------------------------------------------------------------------
1274 1283 ZeroDivisionError Traceback (most recent call last)
1275 1284 Cell In [3], line 1
1276 1285 ----> 1 myfunc(2)
1277 1286
1278 1287 Cell In [2], line 2, in myfunc(z)
1279 1288 1 def myfunc(z):
1280 1289 ----> 2 foo.boo(z-1)
1281 1290
1282 1291 File ~/code/python/ipython/foo.py:3, in boo(x)
1283 1292 2 def boo(x):
1284 1293 ----> 3 return 1/(1-x)
1285 1294
1286 1295 ZeroDivisionError: division by zero
1287 1296
1288 1297 or, with xmode=Plain::
1289 1298
1290 1299 Traceback (most recent call last):
1291 1300 Cell In [12], line 1
1292 1301 myfunc(2)
1293 1302 Cell In [6], line 2 in myfunc
1294 1303 foo.boo(z-1)
1295 1304 File ~/code/python/ipython/foo.py:3 in boo
1296 1305 return 1/(1-x)
1297 1306 ZeroDivisionError: division by zero
1298 1307
1299 1308 :ghpull:`13560`
1300 1309
1301 1310 New setting to silence warning if working inside a virtual environment
1302 1311 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1303 1312
1304 1313 Previously, when starting IPython in a virtual environment without IPython installed (so IPython from the global environment is used), the following warning was printed:
1305 1314
1306 1315 Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
1307 1316
1308 1317 This warning can be permanently silenced by setting ``c.InteractiveShell.warn_venv`` to ``False`` (the default is ``True``).
1309 1318
1310 1319 :ghpull:`13706`
1311 1320
1312 1321 -------
1313 1322
1314 1323 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1315 1324 work on IPython and related libraries.
1316 1325
1317 1326
1318 1327 .. _version 8.4.0:
1319 1328
1320 1329 IPython 8.4.0
1321 1330 -------------
1322 1331
1323 1332 As for 7.34, this version contains a single fix: fix uncaught BdbQuit exceptions on ipdb
1324 1333 exit :ghpull:`13668`, and a single typo fix in documentation: :ghpull:`13682`
1325 1334
1326 1335 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1327 1336 work on IPython and related libraries.
1328 1337
1329 1338
1330 1339 .. _version 8.3.0:
1331 1340
1332 1341 IPython 8.3.0
1333 1342 -------------
1334 1343
1335 1344 - :ghpull:`13625`, using ``?``, ``??``, ``*?`` will not call
1336 1345 ``set_next_input`` as most frontend allow proper multiline editing and it was
1337 1346 causing issues for many users of multi-cell frontends. This has been backported to 7.33
1338 1347
1339 1348
1340 1349 - :ghpull:`13600`, ``pre_run_*``-hooks will now have a ``cell_id`` attribute on
1341 1350 the info object when frontend provides it. This has been backported to 7.33
1342 1351
1343 1352 - :ghpull:`13624`, fixed :kbd:`End` key being broken after accepting an
1344 1353 auto-suggestion.
1345 1354
1346 1355 - :ghpull:`13657` fixed an issue where history from different sessions would be mixed.
1347 1356
1348 1357 .. _version 8.2.0:
1349 1358
1350 1359 IPython 8.2.0
1351 1360 -------------
1352 1361
1353 1362 IPython 8.2 mostly bring bugfixes to IPython.
1354 1363
1355 1364 - Auto-suggestion can now be elected with the ``end`` key. :ghpull:`13566`
1356 1365 - Some traceback issues with ``assert etb is not None`` have been fixed. :ghpull:`13588`
1357 1366 - History is now pulled from the sqitel database and not from in-memory.
1358 1367 In particular when using the ``%paste`` magic, the content of the pasted text will
1359 1368 be part of the history and not the verbatim text ``%paste`` anymore. :ghpull:`13592`
1360 1369 - Fix ``Ctrl-\\`` exit cleanup :ghpull:`13603`
1361 1370 - Fixes to ``ultratb`` ipdb support when used outside of IPython. :ghpull:`13498`
1362 1371
1363 1372
1364 1373 I am still trying to fix and investigate :ghissue:`13598`, which seems to be
1365 1374 random, and would appreciate help if you find a reproducible minimal case. I've
1366 1375 tried to make various changes to the codebase to mitigate it, but a proper fix
1367 1376 will be difficult without understanding the cause.
1368 1377
1369 1378
1370 1379 All the issues on pull-requests for this release can be found in the `8.2
1371 1380 milestone. <https://github.com/ipython/ipython/milestone/100>`__ . And some
1372 1381 documentation only PR can be found as part of the `7.33 milestone
1373 1382 <https://github.com/ipython/ipython/milestone/101>`__ (currently not released).
1374 1383
1375 1384 Thanks to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1376 1385 work on IPython and related libraries.
1377 1386
1378 1387 .. _version 8.1.1:
1379 1388
1380 1389 IPython 8.1.1
1381 1390 -------------
1382 1391
1383 1392 Fix an issue with virtualenv and Python 3.8 introduced in 8.1
1384 1393
1385 1394 Revert :ghpull:`13537` (fix an issue with symlinks in virtualenv) that raises an
1386 1395 error in Python 3.8, and fixed in a different way in :ghpull:`13559`.
1387 1396
1388 1397 .. _version 8.1:
1389 1398
1390 1399 IPython 8.1.0
1391 1400 -------------
1392 1401
1393 1402 IPython 8.1 is the first minor release after 8.0 and fixes a number of bugs and
1394 1403 updates a few behaviors that were problematic with the 8.0 as with many new major
1395 1404 release.
1396 1405
1397 1406 Note that beyond the changes listed here, IPython 8.1.0 also contains all the
1398 1407 features listed in :ref:`version 7.32`.
1399 1408
1400 1409 - Misc and multiple fixes around quotation auto-closing. It is now disabled by
1401 1410 default. Run with ``TerminalInteractiveShell.auto_match=True`` to re-enabled
1402 1411 - Require pygments>=2.4.0 :ghpull:`13459`, this was implicit in the code, but
1403 1412 is now explicit in ``setup.cfg``/``setup.py``
1404 1413 - Docs improvement of ``core.magic_arguments`` examples. :ghpull:`13433`
1405 1414 - Multi-line edit executes too early with await. :ghpull:`13424`
1406 1415
1407 1416 - ``black`` is back as an optional dependency, and autoformatting disabled by
1408 1417 default until some fixes are implemented (black improperly reformat magics).
1409 1418 :ghpull:`13471` Additionally the ability to use ``yapf`` as a code
1410 1419 reformatter has been added :ghpull:`13528` . You can use
1411 1420 ``TerminalInteractiveShell.autoformatter="black"``,
1412 1421 ``TerminalInteractiveShell.autoformatter="yapf"`` to re-enable auto formatting
1413 1422 with black, or switch to yapf.
1414 1423
1415 1424 - Fix and issue where ``display`` was not defined.
1416 1425
1417 1426 - Auto suggestions are now configurable. Currently only
1418 1427 ``AutoSuggestFromHistory`` (default) and ``None``. new provider contribution
1419 1428 welcomed. :ghpull:`13475`
1420 1429
1421 1430 - multiple packaging/testing improvement to simplify downstream packaging
1422 1431 (xfail with reasons, try to not access network...).
1423 1432
1424 1433 - Update deprecation. ``InteractiveShell.magic`` internal method has been
1425 1434 deprecated for many years but did not emit a warning until now.
1426 1435
1427 1436 - internal ``appended_to_syspath`` context manager has been deprecated.
1428 1437
1429 1438 - fix an issue with symlinks in virtualenv :ghpull:`13537` (Reverted in 8.1.1)
1430 1439
1431 1440 - Fix an issue with vim mode, where cursor would not be reset on exit :ghpull:`13472`
1432 1441
1433 1442 - ipython directive now remove only known pseudo-decorators :ghpull:`13532`
1434 1443
1435 1444 - ``IPython/lib/security`` which used to be used for jupyter notebook has been
1436 1445 removed.
1437 1446
1438 1447 - Fix an issue where ``async with`` would execute on new lines. :ghpull:`13436`
1439 1448
1440 1449
1441 1450 We want to remind users that IPython is part of the Jupyter organisations, and
1442 1451 thus governed by a Code of Conduct. Some of the behavior we have seen on GitHub is not acceptable.
1443 1452 Abuse and non-respectful comments on discussion will not be tolerated.
1444 1453
1445 1454 Many thanks to all the contributors to this release, many of the above fixed issues and
1446 1455 new features were done by first time contributors, showing there is still
1447 1456 plenty of easy contribution possible in IPython
1448 1457 . You can find all individual contributions
1449 1458 to this milestone `on github <https://github.com/ipython/ipython/milestone/91>`__.
1450 1459
1451 1460 Thanks as well to the `D. E. Shaw group <https://deshaw.com/>`__ for sponsoring
1452 1461 work on IPython and related libraries. In particular the Lazy autoloading of
1453 1462 magics that you will find described in the 7.32 release notes.
1454 1463
1455 1464
1456 1465 .. _version 8.0.1:
1457 1466
1458 1467 IPython 8.0.1 (CVE-2022-21699)
1459 1468 ------------------------------
1460 1469
1461 1470 IPython 8.0.1, 7.31.1 and 5.11 are security releases that change some default
1462 1471 values in order to prevent potential Execution with Unnecessary Privileges.
1463 1472
1464 1473 Almost all version of IPython looks for configuration and profiles in current
1465 1474 working directory. Since IPython was developed before pip and environments
1466 1475 existed it was used a convenient way to load code/packages in a project
1467 1476 dependent way.
1468 1477
1469 1478 In 2022, it is not necessary anymore, and can lead to confusing behavior where
1470 1479 for example cloning a repository and starting IPython or loading a notebook from
1471 1480 any Jupyter-Compatible interface that has ipython set as a kernel can lead to
1472 1481 code execution.
1473 1482
1474 1483
1475 1484 I did not find any standard way for packaged to advertise CVEs they fix, I'm
1476 1485 thus trying to add a ``__patched_cves__`` attribute to the IPython module that
1477 1486 list the CVEs that should have been fixed. This attribute is informational only
1478 1487 as if a executable has a flaw, this value can always be changed by an attacker.
1479 1488
1480 1489 .. code::
1481 1490
1482 1491 In [1]: import IPython
1483 1492
1484 1493 In [2]: IPython.__patched_cves__
1485 1494 Out[2]: {'CVE-2022-21699'}
1486 1495
1487 1496 In [3]: 'CVE-2022-21699' in IPython.__patched_cves__
1488 1497 Out[3]: True
1489 1498
1490 1499 Thus starting with this version:
1491 1500
1492 1501 - The current working directory is not searched anymore for profiles or
1493 1502 configurations files.
1494 1503 - Added a ``__patched_cves__`` attribute (set of strings) to IPython module that contain
1495 1504 the list of fixed CVE. This is informational only.
1496 1505
1497 1506 Further details can be read on the `GitHub Advisory <https://github.com/ipython/ipython/security/advisories/GHSA-pq7m-3gw7-gq5x>`__
1498 1507
1499 1508
1500 1509 .. _version 8.0:
1501 1510
1502 1511 IPython 8.0
1503 1512 -----------
1504 1513
1505 1514 IPython 8.0 is bringing a large number of new features and improvements to both the
1506 1515 user of the terminal and of the kernel via Jupyter. The removal of compatibility
1507 1516 with an older version of Python is also the opportunity to do a couple of
1508 1517 performance improvements in particular with respect to startup time.
1509 1518 The 8.x branch started diverging from its predecessor around IPython 7.12
1510 1519 (January 2020).
1511 1520
1512 1521 This release contains 250+ pull requests, in addition to many of the features
1513 1522 and backports that have made it to the 7.x branch. Please see the
1514 1523 `8.0 milestone <https://github.com/ipython/ipython/milestone/73?closed=1>`__ for the full list of pull requests.
1515 1524
1516 1525 Please feel free to send pull requests to update those notes after release,
1517 1526 I have likely forgotten a few things reviewing 250+ PRs.
1518 1527
1519 1528 Dependencies changes/downstream packaging
1520 1529 -----------------------------------------
1521 1530
1522 1531 Most of our building steps have been changed to be (mostly) declarative
1523 1532 and follow PEP 517. We are trying to completely remove ``setup.py`` (:ghpull:`13238`) and are
1524 1533 looking for help to do so.
1525 1534
1526 1535 - minimum supported ``traitlets`` version is now 5+
1527 1536 - we now require ``stack_data``
1528 1537 - minimal Python is now 3.8
1529 1538 - ``nose`` is not a testing requirement anymore
1530 1539 - ``pytest`` replaces nose.
1531 1540 - ``iptest``/``iptest3`` cli entrypoints do not exist anymore.
1532 1541 - the minimum officially ​supported ``numpy`` version has been bumped, but this should
1533 1542 not have much effect on packaging.
1534 1543
1535 1544
1536 1545 Deprecation and removal
1537 1546 -----------------------
1538 1547
1539 1548 We removed almost all features, arguments, functions, and modules that were
1540 1549 marked as deprecated between IPython 1.0 and 5.0. As a reminder, 5.0 was released
1541 1550 in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in May 2020.
1542 1551 The few remaining deprecated features we left have better deprecation warnings
1543 1552 or have been turned into explicit errors for better error messages.
1544 1553
1545 1554 I will use this occasion to add the following requests to anyone emitting a
1546 1555 deprecation warning:
1547 1556
1548 1557 - Please add at least ``stacklevel=2`` so that the warning is emitted into the
1549 1558 caller context, and not the callee one.
1550 1559 - Please add **since which version** something is deprecated.
1551 1560
1552 1561 As a side note, it is much easier to conditionally compare version
1553 1562 numbers rather than using ``try/except`` when functionality changes with a version.
1554 1563
1555 1564 I won't list all the removed features here, but modules like ``IPython.kernel``,
1556 1565 which was just a shim module around ``ipykernel`` for the past 8 years, have been
1557 1566 removed, and so many other similar things that pre-date the name **Jupyter**
1558 1567 itself.
1559 1568
1560 1569 We no longer need to add ``IPython.extensions`` to the PYTHONPATH because that is being
1561 1570 handled by ``load_extension``.
1562 1571
1563 1572 We are also removing ``Cythonmagic``, ``sympyprinting`` and ``rmagic`` as they are now in
1564 1573 other packages and no longer need to be inside IPython.
1565 1574
1566 1575
1567 1576 Documentation
1568 1577 -------------
1569 1578
1570 1579 The majority of our docstrings have now been reformatted and automatically fixed by
1571 1580 the experimental `VΓ©lin <https://pypi.org/project/velin/>`_ project to conform
1572 1581 to numpydoc.
1573 1582
1574 1583 Type annotations
1575 1584 ----------------
1576 1585
1577 1586 While IPython itself is highly dynamic and can't be completely typed, many of
1578 1587 the functions now have type annotations, and part of the codebase is now checked
1579 1588 by mypy.
1580 1589
1581 1590
1582 1591 Featured changes
1583 1592 ----------------
1584 1593
1585 1594 Here is a features list of changes in IPython 8.0. This is of course non-exhaustive.
1586 1595 Please note as well that many features have been added in the 7.x branch as well
1587 1596 (and hence why you want to read the 7.x what's new notes), in particular
1588 1597 features contributed by QuantStack (with respect to debugger protocol and Xeus
1589 1598 Python), as well as many debugger features that I was pleased to implement as
1590 1599 part of my work at QuanSight and sponsored by DE Shaw.
1591 1600
1592 1601 Traceback improvements
1593 1602 ~~~~~~~~~~~~~~~~~~~~~~
1594 1603
1595 1604 Previously, error tracebacks for errors happening in code cells were showing a
1596 1605 hash, the one used for compiling the Python AST::
1597 1606
1598 1607 In [1]: def foo():
1599 1608 ...: return 3 / 0
1600 1609 ...:
1601 1610
1602 1611 In [2]: foo()
1603 1612 ---------------------------------------------------------------------------
1604 1613 ZeroDivisionError Traceback (most recent call last)
1605 1614 <ipython-input-2-c19b6d9633cf> in <module>
1606 1615 ----> 1 foo()
1607 1616
1608 1617 <ipython-input-1-1595a74c32d5> in foo()
1609 1618 1 def foo():
1610 1619 ----> 2 return 3 / 0
1611 1620 3
1612 1621
1613 1622 ZeroDivisionError: division by zero
1614 1623
1615 1624 The error traceback is now correctly formatted, showing the cell number in which the error happened::
1616 1625
1617 1626 In [1]: def foo():
1618 1627 ...: return 3 / 0
1619 1628 ...:
1620 1629
1621 1630 Input In [2]: foo()
1622 1631 ---------------------------------------------------------------------------
1623 1632 ZeroDivisionError Traceback (most recent call last)
1624 1633 input In [2], in <module>
1625 1634 ----> 1 foo()
1626 1635
1627 1636 Input In [1], in foo()
1628 1637 1 def foo():
1629 1638 ----> 2 return 3 / 0
1630 1639
1631 1640 ZeroDivisionError: division by zero
1632 1641
1633 1642 The ``stack_data`` package has been integrated, which provides smarter information in the traceback;
1634 1643 in particular it will highlight the AST node where an error occurs which can help to quickly narrow down errors.
1635 1644
1636 1645 For example in the following snippet::
1637 1646
1638 1647 def foo(i):
1639 1648 x = [[[0]]]
1640 1649 return x[0][i][0]
1641 1650
1642 1651
1643 1652 def bar():
1644 1653 return foo(0) + foo(
1645 1654 1
1646 1655 ) + foo(2)
1647 1656
1648 1657
1649 1658 calling ``bar()`` would raise an ``IndexError`` on the return line of ``foo``,
1650 1659 and IPython 8.0 is capable of telling you where the index error occurs::
1651 1660
1652 1661
1653 1662 IndexError
1654 1663 Input In [2], in <module>
1655 1664 ----> 1 bar()
1656 1665 ^^^^^
1657 1666
1658 1667 Input In [1], in bar()
1659 1668 6 def bar():
1660 1669 ----> 7 return foo(0) + foo(
1661 1670 ^^^^
1662 1671 8 1
1663 1672 ^^^^^^^^
1664 1673 9 ) + foo(2)
1665 1674 ^^^^
1666 1675
1667 1676 Input In [1], in foo(i)
1668 1677 1 def foo(i):
1669 1678 2 x = [[[0]]]
1670 1679 ----> 3 return x[0][i][0]
1671 1680 ^^^^^^^
1672 1681
1673 1682 The corresponding locations marked here with ``^`` will show up highlighted in
1674 1683 the terminal and notebooks.
1675 1684
1676 1685 Finally, a colon ``::`` and line number is appended after a filename in
1677 1686 traceback::
1678 1687
1679 1688
1680 1689 ZeroDivisionError Traceback (most recent call last)
1681 1690 File ~/error.py:4, in <module>
1682 1691 1 def f():
1683 1692 2 1/0
1684 1693 ----> 4 f()
1685 1694
1686 1695 File ~/error.py:2, in f()
1687 1696 1 def f():
1688 1697 ----> 2 1/0
1689 1698
1690 1699 Many terminals and editors have integrations enabling you to directly jump to the
1691 1700 relevant file/line when this syntax is used, so this small addition may have a high
1692 1701 impact on productivity.
1693 1702
1694 1703
1695 1704 Autosuggestions
1696 1705 ~~~~~~~~~~~~~~~
1697 1706
1698 1707 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>`__.
1699 1708
1700 1709 `Ptpython <https://github.com/prompt-toolkit/ptpython#ptpython>`__ allows users to enable this feature in
1701 1710 `ptpython/config.py <https://github.com/prompt-toolkit/ptpython/blob/master/examples/ptpython_config/config.py#L90>`__.
1702 1711
1703 1712 This feature allows users to accept autosuggestions with ctrl e, ctrl f,
1704 1713 or right arrow as described below.
1705 1714
1706 1715 1. Start ipython
1707 1716
1708 1717 .. image:: ../_images/8.0/auto_suggest_1_prompt_no_text.png
1709 1718
1710 1719 2. Run ``print("hello")``
1711 1720
1712 1721 .. image:: ../_images/8.0/auto_suggest_2_print_hello_suggest.png
1713 1722
1714 1723 3. start typing ``print`` again to see the autosuggestion
1715 1724
1716 1725 .. image:: ../_images/8.0/auto_suggest_3_print_hello_suggest.png
1717 1726
1718 1727 4. Press ``ctrl-f``, or ``ctrl-e``, or ``right-arrow`` to accept the suggestion
1719 1728
1720 1729 .. image:: ../_images/8.0/auto_suggest_4_print_hello.png
1721 1730
1722 1731 You can also complete word by word:
1723 1732
1724 1733 1. Run ``def say_hello(): print("hello")``
1725 1734
1726 1735 .. image:: ../_images/8.0/auto_suggest_second_prompt.png
1727 1736
1728 1737 2. Start typing the first letter if ``def`` to see the autosuggestion
1729 1738
1730 1739 .. image:: ../_images/8.0/auto_suggest_d_phantom.png
1731 1740
1732 1741 3. Press ``alt-f`` (or ``escape`` followed by ``f``), to accept the first word of the suggestion
1733 1742
1734 1743 .. image:: ../_images/8.0/auto_suggest_def_phantom.png
1735 1744
1736 1745 Importantly, this feature does not interfere with tab completion:
1737 1746
1738 1747 1. After running ``def say_hello(): print("hello")``, press d
1739 1748
1740 1749 .. image:: ../_images/8.0/auto_suggest_d_phantom.png
1741 1750
1742 1751 2. Press Tab to start tab completion
1743 1752
1744 1753 .. image:: ../_images/8.0/auto_suggest_d_completions.png
1745 1754
1746 1755 3A. Press Tab again to select the first option
1747 1756
1748 1757 .. image:: ../_images/8.0/auto_suggest_def_completions.png
1749 1758
1750 1759 3B. Press ``alt f`` (``escape``, ``f``) to accept to accept the first word of the suggestion
1751 1760
1752 1761 .. image:: ../_images/8.0/auto_suggest_def_phantom.png
1753 1762
1754 1763 3C. Press ``ctrl-f`` or ``ctrl-e`` to accept the entire suggestion
1755 1764
1756 1765 .. image:: ../_images/8.0/auto_suggest_match_parens.png
1757 1766
1758 1767
1759 1768 Currently, autosuggestions are only shown in the emacs or vi insert editing modes:
1760 1769
1761 1770 - The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode.
1762 1771 - 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/>`__.
1763 1772
1764 1773
1765 1774 Show pinfo information in ipdb using "?" and "??"
1766 1775 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1767 1776
1768 1777 In IPDB, it is now possible to show the information about an object using "?"
1769 1778 and "??", in much the same way that it can be done when using the IPython prompt::
1770 1779
1771 1780 ipdb> partial?
1772 1781 Init signature: partial(self, /, *args, **kwargs)
1773 1782 Docstring:
1774 1783 partial(func, *args, **keywords) - new function with partial application
1775 1784 of the given arguments and keywords.
1776 1785 File: ~/.pyenv/versions/3.8.6/lib/python3.8/functools.py
1777 1786 Type: type
1778 1787 Subclasses:
1779 1788
1780 1789 Previously, ``pinfo`` or ``pinfo2`` command had to be used for this purpose.
1781 1790
1782 1791
1783 1792 Autoreload 3 feature
1784 1793 ~~~~~~~~~~~~~~~~~~~~
1785 1794
1786 1795 Example: When an IPython session is run with the 'autoreload' extension loaded,
1787 1796 you will now have the option '3' to select, which means the following:
1788 1797
1789 1798 1. replicate all functionality from option 2
1790 1799 2. autoload all new funcs/classes/enums/globals from the module when they are added
1791 1800 3. autoload all newly imported funcs/classes/enums/globals from external modules
1792 1801
1793 1802 Try ``%autoreload 3`` in an IPython session after running ``%load_ext autoreload``.
1794 1803
1795 1804 For more information please see the following unit test : ``extensions/tests/test_autoreload.py:test_autoload_newly_added_objects``
1796 1805
1797 1806 Auto formatting with black in the CLI
1798 1807 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1799 1808
1800 1809 This feature was present in 7.x, but disabled by default.
1801 1810
1802 1811 In 8.0, input was automatically reformatted with Black when black was installed.
1803 1812 This feature has been reverted for the time being.
1804 1813 You can re-enable it by setting ``TerminalInteractiveShell.autoformatter`` to ``"black"``
1805 1814
1806 1815 History Range Glob feature
1807 1816 ~~~~~~~~~~~~~~~~~~~~~~~~~~
1808 1817
1809 1818 Previously, when using ``%history``, users could specify either
1810 1819 a range of sessions and lines, for example:
1811 1820
1812 1821 .. code-block:: python
1813 1822
1814 1823 ~8/1-~6/5 # see history from the first line of 8 sessions ago,
1815 1824 # to the fifth line of 6 sessions ago.``
1816 1825
1817 1826 Or users could specify a glob pattern:
1818 1827
1819 1828 .. code-block:: python
1820 1829
1821 1830 -g <pattern> # glob ALL history for the specified pattern.
1822 1831
1823 1832 However users could *not* specify both.
1824 1833
1825 1834 If a user *did* specify both a range and a glob pattern,
1826 1835 then the glob pattern would be used (globbing *all* history) *and the range would be ignored*.
1827 1836
1828 1837 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.
1829 1838
1830 1839 Don't start a multi-line cell with sunken parenthesis
1831 1840 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1832 1841
1833 1842 From now on, IPython will not ask for the next line of input when given a single
1834 1843 line with more closing than opening brackets. For example, this means that if
1835 1844 you (mis)type ``]]`` instead of ``[]``, a ``SyntaxError`` will show up, instead of
1836 1845 the ``...:`` prompt continuation.
1837 1846
1838 1847 IPython shell for ipdb interact
1839 1848 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1840 1849
1841 1850 The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``.
1842 1851
1843 1852 Automatic Vi prompt stripping
1844 1853 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1845 1854
1846 1855 When pasting code into IPython, it will strip the leading prompt characters if
1847 1856 there are any. For example, you can paste the following code into the console -
1848 1857 it will still work, even though each line is prefixed with prompts (``In``,
1849 1858 ``Out``)::
1850 1859
1851 1860 In [1]: 2 * 2 == 4
1852 1861 Out[1]: True
1853 1862
1854 1863 In [2]: print("This still works as pasted")
1855 1864
1856 1865
1857 1866 Previously, this was not the case for the Vi-mode prompts::
1858 1867
1859 1868 In [1]: [ins] In [13]: 2 * 2 == 4
1860 1869 ...: Out[13]: True
1861 1870 ...:
1862 1871 File "<ipython-input-1-727bb88eaf33>", line 1
1863 1872 [ins] In [13]: 2 * 2 == 4
1864 1873 ^
1865 1874 SyntaxError: invalid syntax
1866 1875
1867 1876 This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are
1868 1877 skipped just as the normal ``In`` would be.
1869 1878
1870 1879 IPython shell can be started in the Vi mode using ``ipython --TerminalInteractiveShell.editing_mode=vi``,
1871 1880 You should be able to change mode dynamically with ``%config TerminalInteractiveShell.editing_mode='vi'``
1872 1881
1873 1882 Empty History Ranges
1874 1883 ~~~~~~~~~~~~~~~~~~~~
1875 1884
1876 1885 A number of magics that take history ranges can now be used with an empty
1877 1886 range. These magics are:
1878 1887
1879 1888 * ``%save``
1880 1889 * ``%load``
1881 1890 * ``%pastebin``
1882 1891 * ``%pycat``
1883 1892
1884 1893 Using them this way will make them take the history of the current session up
1885 1894 to the point of the magic call (such that the magic itself will not be
1886 1895 included).
1887 1896
1888 1897 Therefore it is now possible to save the whole history to a file using
1889 1898 ``%save <filename>``, load and edit it using ``%load`` (makes for a nice usage
1890 1899 when followed with :kbd:`F2`), send it to `dpaste.org <http://dpast.org>`_ using
1891 1900 ``%pastebin``, or view the whole thing syntax-highlighted with a single
1892 1901 ``%pycat``.
1893 1902
1894 1903
1895 1904 Windows timing implementation: Switch to process_time
1896 1905 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1897 1906 Timing on Windows, for example with ``%%time``, was changed from being based on ``time.perf_counter``
1898 1907 (which counted time even when the process was sleeping) to being based on ``time.process_time`` instead
1899 1908 (which only counts CPU time). This brings it closer to the behavior on Linux. See :ghpull:`12984`.
1900 1909
1901 1910 Miscellaneous
1902 1911 ~~~~~~~~~~~~~
1903 1912 - Non-text formatters are not disabled in the terminal, which should simplify
1904 1913 writing extensions displaying images or other mimetypes in supporting terminals.
1905 1914 :ghpull:`12315`
1906 1915 - It is now possible to automatically insert matching brackets in Terminal IPython using the
1907 1916 ``TerminalInteractiveShell.auto_match=True`` option. :ghpull:`12586`
1908 1917 - We are thinking of deprecating the current ``%%javascript`` magic in favor of a better replacement. See :ghpull:`13376`.
1909 1918 - ``~`` is now expanded when part of a path in most magics :ghpull:`13385`
1910 1919 - ``%/%%timeit`` magic now adds a comma every thousands to make reading a long number easier :ghpull:`13379`
1911 1920 - ``"info"`` messages can now be customised to hide some fields :ghpull:`13343`
1912 1921 - ``collections.UserList`` now pretty-prints :ghpull:`13320`
1913 1922 - The debugger now has a persistent history, which should make it less
1914 1923 annoying to retype commands :ghpull:`13246`
1915 1924 - ``!pip`` ``!conda`` ``!cd`` or ``!ls`` are likely doing the wrong thing. We
1916 1925 now warn users if they use one of those commands. :ghpull:`12954`
1917 1926 - Make ``%precision`` work for ``numpy.float64`` type :ghpull:`12902`
1918 1927
1919 1928 Re-added support for XDG config directories
1920 1929 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1921 1930
1922 1931 XDG support through the years comes and goes. There is a tension between having
1923 1932 an identical location for configuration in all platforms versus having simple instructions.
1924 1933 After initial failures a couple of years ago, IPython was modified to automatically migrate XDG
1925 1934 config files back into ``~/.ipython``. That migration code has now been removed.
1926 1935 IPython now checks the XDG locations, so if you _manually_ move your config
1927 1936 files to your preferred location, IPython will not move them back.
1928 1937
1929 1938
1930 1939 Preparing for Python 3.10
1931 1940 -------------------------
1932 1941
1933 1942 To prepare for Python 3.10, we have started working on removing reliance and
1934 1943 any dependency that is not compatible with Python 3.10. This includes migrating our
1935 1944 test suite to pytest and starting to remove nose. This also means that the
1936 1945 ``iptest`` command is now gone and all testing is via pytest.
1937 1946
1938 1947 This was in large part thanks to the NumFOCUS Small Developer grant, which enabled us to
1939 1948 allocate \$4000 to hire `Nikita Kniazev (@Kojoley) <https://github.com/Kojoley>`_,
1940 1949 who did a fantastic job at updating our code base, migrating to pytest, pushing
1941 1950 our coverage, and fixing a large number of bugs. I highly recommend contacting
1942 1951 them if you need help with C++ and Python projects.
1943 1952
1944 1953 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+>`__
1945 1954
1946 1955 Removing support for older Python versions
1947 1956 ------------------------------------------
1948 1957
1949 1958
1950 1959 We are removing support for Python up through 3.7, allowing internal code to use the more
1951 1960 efficient ``pathlib`` and to make better use of type annotations.
1952 1961
1953 1962 .. image:: ../_images/8.0/pathlib_pathlib_everywhere.jpg
1954 1963 :alt: "Meme image of Toy Story with Woody and Buzz, with the text 'pathlib, pathlib everywhere'"
1955 1964
1956 1965
1957 1966 We had about 34 PRs only to update some logic to update some functions from managing strings to
1958 1967 using Pathlib.
1959 1968
1960 1969 The completer has also seen significant updates and now makes use of newer Jedi APIs,
1961 1970 offering faster and more reliable tab completion.
1962 1971
1963 1972 Misc Statistics
1964 1973 ---------------
1965 1974
1966 1975 Here are some numbers::
1967 1976
1968 1977 7.x: 296 files, 12561 blank lines, 20282 comments, 35142 line of code.
1969 1978 8.0: 252 files, 12053 blank lines, 19232 comments, 34505 line of code.
1970 1979
1971 1980 $ git diff --stat 7.x...master | tail -1
1972 1981 340 files changed, 13399 insertions(+), 12421 deletions(-)
1973 1982
1974 1983 We have commits from 162 authors, who contributed 1916 commits in 23 month, excluding merges (to not bias toward
1975 1984 maintainers pushing buttons).::
1976 1985
1977 1986 $ git shortlog -s --no-merges 7.x...master | sort -nr
1978 1987 535 Matthias Bussonnier
1979 1988 86 Nikita Kniazev
1980 1989 69 Blazej Michalik
1981 1990 49 Samuel Gaist
1982 1991 27 Itamar Turner-Trauring
1983 1992 18 Spas Kalaydzhisyki
1984 1993 17 Thomas Kluyver
1985 1994 17 Quentin Peter
1986 1995 17 James Morris
1987 1996 17 Artur Svistunov
1988 1997 15 Bart Skowron
1989 1998 14 Alex Hall
1990 1999 13 rushabh-v
1991 2000 13 Terry Davis
1992 2001 13 Benjamin Ragan-Kelley
1993 2002 8 martinRenou
1994 2003 8 farisachugthai
1995 2004 7 dswij
1996 2005 7 Gal B
1997 2006 7 Corentin Cadiou
1998 2007 6 yuji96
1999 2008 6 Martin Skarzynski
2000 2009 6 Justin Palmer
2001 2010 6 Daniel Goldfarb
2002 2011 6 Ben Greiner
2003 2012 5 Sammy Al Hashemi
2004 2013 5 Paul Ivanov
2005 2014 5 Inception95
2006 2015 5 Eyenpi
2007 2016 5 Douglas Blank
2008 2017 5 Coco Mishra
2009 2018 5 Bibo Hao
2010 2019 5 AndrΓ© A. Gomes
2011 2020 5 Ahmed Fasih
2012 2021 4 takuya fujiwara
2013 2022 4 palewire
2014 2023 4 Thomas A Caswell
2015 2024 4 Talley Lambert
2016 2025 4 Scott Sanderson
2017 2026 4 Ram Rachum
2018 2027 4 Nick Muoh
2019 2028 4 Nathan Goldbaum
2020 2029 4 Mithil Poojary
2021 2030 4 Michael T
2022 2031 4 Jakub Klus
2023 2032 4 Ian Castleden
2024 2033 4 Eli Rykoff
2025 2034 4 Ashwin Vishnu
2026 2035 3 谭九鼎
2027 2036 3 sleeping
2028 2037 3 Sylvain Corlay
2029 2038 3 Peter Corke
2030 2039 3 Paul Bissex
2031 2040 3 Matthew Feickert
2032 2041 3 Fernando Perez
2033 2042 3 Eric Wieser
2034 2043 3 Daniel Mietchen
2035 2044 3 Aditya Sathe
2036 2045 3 007vedant
2037 2046 2 rchiodo
2038 2047 2 nicolaslazo
2039 2048 2 luttik
2040 2049 2 gorogoroumaru
2041 2050 2 foobarbyte
2042 2051 2 bar-hen
2043 2052 2 Theo Ouzhinski
2044 2053 2 Strawkage
2045 2054 2 Samreen Zarroug
2046 2055 2 Pete Blois
2047 2056 2 Meysam Azad
2048 2057 2 Matthieu Ancellin
2049 2058 2 Mark Schmitz
2050 2059 2 Maor Kleinberger
2051 2060 2 MRCWirtz
2052 2061 2 Lumir Balhar
2053 2062 2 Julien Rabinow
2054 2063 2 Juan Luis Cano RodrΓ­guez
2055 2064 2 Joyce Er
2056 2065 2 Jakub
2057 2066 2 Faris A Chugthai
2058 2067 2 Ethan Madden
2059 2068 2 Dimitri Papadopoulos
2060 2069 2 Diego Fernandez
2061 2070 2 Daniel Shimon
2062 2071 2 Coco Bennett
2063 2072 2 Carlos Cordoba
2064 2073 2 Boyuan Liu
2065 2074 2 BaoGiang HoangVu
2066 2075 2 Augusto
2067 2076 2 Arthur Svistunov
2068 2077 2 Arthur Moreira
2069 2078 2 Ali Nabipour
2070 2079 2 Adam Hackbarth
2071 2080 1 richard
2072 2081 1 linar-jether
2073 2082 1 lbennett
2074 2083 1 juacrumar
2075 2084 1 gpotter2
2076 2085 1 digitalvirtuoso
2077 2086 1 dalthviz
2078 2087 1 Yonatan Goldschmidt
2079 2088 1 Tomasz KΕ‚oczko
2080 2089 1 Tobias Bengfort
2081 2090 1 Timur Kushukov
2082 2091 1 Thomas
2083 2092 1 Snir Broshi
2084 2093 1 Shao Yang Hong
2085 2094 1 Sanjana-03
2086 2095 1 Romulo Filho
2087 2096 1 Rodolfo Carvalho
2088 2097 1 Richard Shadrach
2089 2098 1 Reilly Tucker Siemens
2090 2099 1 Rakessh Roshan
2091 2100 1 Piers Titus van der Torren
2092 2101 1 PhanatosZou
2093 2102 1 Pavel Safronov
2094 2103 1 Paulo S. Costa
2095 2104 1 Paul McCarthy
2096 2105 1 NotWearingPants
2097 2106 1 Naelson Douglas
2098 2107 1 Michael Tiemann
2099 2108 1 Matt Wozniski
2100 2109 1 Markus Wageringel
2101 2110 1 Marcus Wirtz
2102 2111 1 Marcio Mazza
2103 2112 1 LumΓ­r 'Frenzy' Balhar
2104 2113 1 Lightyagami1
2105 2114 1 Leon Anavi
2106 2115 1 LeafyLi
2107 2116 1 L0uisJ0shua
2108 2117 1 Kyle Cutler
2109 2118 1 Krzysztof Cybulski
2110 2119 1 Kevin Kirsche
2111 2120 1 KIU Shueng Chuan
2112 2121 1 Jonathan Slenders
2113 2122 1 Jay Qi
2114 2123 1 Jake VanderPlas
2115 2124 1 Iwan Briquemont
2116 2125 1 Hussaina Begum Nandyala
2117 2126 1 Gordon Ball
2118 2127 1 Gabriel Simonetto
2119 2128 1 Frank Tobia
2120 2129 1 Erik
2121 2130 1 Elliott Sales de Andrade
2122 2131 1 Daniel Hahler
2123 2132 1 Dan Green-Leipciger
2124 2133 1 Dan Green
2125 2134 1 Damian Yurzola
2126 2135 1 Coon, Ethan T
2127 2136 1 Carol Willing
2128 2137 1 Brian Lee
2129 2138 1 Brendan Gerrity
2130 2139 1 Blake Griffin
2131 2140 1 Bastian Ebeling
2132 2141 1 Bartosz Telenczuk
2133 2142 1 Ankitsingh6299
2134 2143 1 Andrew Port
2135 2144 1 Andrew J. Hesford
2136 2145 1 Albert Zhang
2137 2146 1 Adam Johnson
2138 2147
2139 2148 This does not, of course, represent non-code contributions, for which we are also grateful.
2140 2149
2141 2150
2142 2151 API Changes using Frappuccino
2143 2152 -----------------------------
2144 2153
2145 2154 This is an experimental exhaustive API difference using `Frappuccino <https://pypi.org/project/frappuccino/>`_
2146 2155
2147 2156
2148 2157 The following items are new in IPython 8.0 ::
2149 2158
2150 2159 + IPython.core.async_helpers.get_asyncio_loop()
2151 2160 + IPython.core.completer.Dict
2152 2161 + IPython.core.completer.Pattern
2153 2162 + IPython.core.completer.Sequence
2154 2163 + IPython.core.completer.__skip_doctest__
2155 2164 + IPython.core.debugger.Pdb.precmd(self, line)
2156 2165 + IPython.core.debugger.__skip_doctest__
2157 2166 + IPython.core.display.__getattr__(name)
2158 2167 + IPython.core.display.warn
2159 2168 + IPython.core.display_functions
2160 2169 + IPython.core.display_functions.DisplayHandle
2161 2170 + IPython.core.display_functions.DisplayHandle.display(self, obj, **kwargs)
2162 2171 + IPython.core.display_functions.DisplayHandle.update(self, obj, **kwargs)
2163 2172 + IPython.core.display_functions.__all__
2164 2173 + IPython.core.display_functions.__builtins__
2165 2174 + IPython.core.display_functions.__cached__
2166 2175 + IPython.core.display_functions.__doc__
2167 2176 + IPython.core.display_functions.__file__
2168 2177 + IPython.core.display_functions.__loader__
2169 2178 + IPython.core.display_functions.__name__
2170 2179 + IPython.core.display_functions.__package__
2171 2180 + IPython.core.display_functions.__spec__
2172 2181 + IPython.core.display_functions.b2a_hex
2173 2182 + IPython.core.display_functions.clear_output(wait=False)
2174 2183 + IPython.core.display_functions.display(*objs, include='None', exclude='None', metadata='None', transient='None', display_id='None', raw=False, clear=False, **kwargs)
2175 2184 + IPython.core.display_functions.publish_display_data(data, metadata='None', source='<deprecated>', *, transient='None', **kwargs)
2176 2185 + IPython.core.display_functions.update_display(obj, *, display_id, **kwargs)
2177 2186 + IPython.core.extensions.BUILTINS_EXTS
2178 2187 + IPython.core.inputtransformer2.has_sunken_brackets(tokens)
2179 2188 + IPython.core.interactiveshell.Callable
2180 2189 + IPython.core.interactiveshell.__annotations__
2181 2190 + IPython.core.ultratb.List
2182 2191 + IPython.core.ultratb.Tuple
2183 2192 + IPython.lib.pretty.CallExpression
2184 2193 + IPython.lib.pretty.CallExpression.factory(name)
2185 2194 + IPython.lib.pretty.RawStringLiteral
2186 2195 + IPython.lib.pretty.RawText
2187 2196 + IPython.terminal.debugger.TerminalPdb.do_interact(self, arg)
2188 2197 + IPython.terminal.embed.Set
2189 2198
2190 2199 The following items have been removed (or moved to superclass)::
2191 2200
2192 2201 - IPython.core.application.BaseIPythonApplication.initialize_subcommand
2193 2202 - IPython.core.completer.Sentinel
2194 2203 - IPython.core.completer.skip_doctest
2195 2204 - IPython.core.debugger.Tracer
2196 2205 - IPython.core.display.DisplayHandle
2197 2206 - IPython.core.display.DisplayHandle.display
2198 2207 - IPython.core.display.DisplayHandle.update
2199 2208 - IPython.core.display.b2a_hex
2200 2209 - IPython.core.display.clear_output
2201 2210 - IPython.core.display.display
2202 2211 - IPython.core.display.publish_display_data
2203 2212 - IPython.core.display.update_display
2204 2213 - IPython.core.excolors.Deprec
2205 2214 - IPython.core.excolors.ExceptionColors
2206 2215 - IPython.core.history.warn
2207 2216 - IPython.core.hooks.late_startup_hook
2208 2217 - IPython.core.hooks.pre_run_code_hook
2209 2218 - IPython.core.hooks.shutdown_hook
2210 2219 - IPython.core.interactiveshell.InteractiveShell.init_deprecation_warnings
2211 2220 - IPython.core.interactiveshell.InteractiveShell.init_readline
2212 2221 - IPython.core.interactiveshell.InteractiveShell.write
2213 2222 - IPython.core.interactiveshell.InteractiveShell.write_err
2214 2223 - IPython.core.interactiveshell.get_default_colors
2215 2224 - IPython.core.interactiveshell.removed_co_newlocals
2216 2225 - IPython.core.magics.execution.ExecutionMagics.profile_missing_notice
2217 2226 - IPython.core.magics.script.PIPE
2218 2227 - IPython.core.prefilter.PrefilterManager.init_transformers
2219 2228 - IPython.core.release.classifiers
2220 2229 - IPython.core.release.description
2221 2230 - IPython.core.release.keywords
2222 2231 - IPython.core.release.long_description
2223 2232 - IPython.core.release.name
2224 2233 - IPython.core.release.platforms
2225 2234 - IPython.core.release.url
2226 2235 - IPython.core.ultratb.VerboseTB.format_records
2227 2236 - IPython.core.ultratb.find_recursion
2228 2237 - IPython.core.ultratb.findsource
2229 2238 - IPython.core.ultratb.fix_frame_records_filenames
2230 2239 - IPython.core.ultratb.inspect_error
2231 2240 - IPython.core.ultratb.is_recursion_error
2232 2241 - IPython.core.ultratb.with_patch_inspect
2233 2242 - IPython.external.__all__
2234 2243 - IPython.external.__builtins__
2235 2244 - IPython.external.__cached__
2236 2245 - IPython.external.__doc__
2237 2246 - IPython.external.__file__
2238 2247 - IPython.external.__loader__
2239 2248 - IPython.external.__name__
2240 2249 - IPython.external.__package__
2241 2250 - IPython.external.__path__
2242 2251 - IPython.external.__spec__
2243 2252 - IPython.kernel.KernelConnectionInfo
2244 2253 - IPython.kernel.__builtins__
2245 2254 - IPython.kernel.__cached__
2246 2255 - IPython.kernel.__warningregistry__
2247 2256 - IPython.kernel.pkg
2248 2257 - IPython.kernel.protocol_version
2249 2258 - IPython.kernel.protocol_version_info
2250 2259 - IPython.kernel.src
2251 2260 - IPython.kernel.version_info
2252 2261 - IPython.kernel.warn
2253 2262 - IPython.lib.backgroundjobs
2254 2263 - IPython.lib.backgroundjobs.BackgroundJobBase
2255 2264 - IPython.lib.backgroundjobs.BackgroundJobBase.run
2256 2265 - IPython.lib.backgroundjobs.BackgroundJobBase.traceback
2257 2266 - IPython.lib.backgroundjobs.BackgroundJobExpr
2258 2267 - IPython.lib.backgroundjobs.BackgroundJobExpr.call
2259 2268 - IPython.lib.backgroundjobs.BackgroundJobFunc
2260 2269 - IPython.lib.backgroundjobs.BackgroundJobFunc.call
2261 2270 - IPython.lib.backgroundjobs.BackgroundJobManager
2262 2271 - IPython.lib.backgroundjobs.BackgroundJobManager.flush
2263 2272 - IPython.lib.backgroundjobs.BackgroundJobManager.new
2264 2273 - IPython.lib.backgroundjobs.BackgroundJobManager.remove
2265 2274 - IPython.lib.backgroundjobs.BackgroundJobManager.result
2266 2275 - IPython.lib.backgroundjobs.BackgroundJobManager.status
2267 2276 - IPython.lib.backgroundjobs.BackgroundJobManager.traceback
2268 2277 - IPython.lib.backgroundjobs.__builtins__
2269 2278 - IPython.lib.backgroundjobs.__cached__
2270 2279 - IPython.lib.backgroundjobs.__doc__
2271 2280 - IPython.lib.backgroundjobs.__file__
2272 2281 - IPython.lib.backgroundjobs.__loader__
2273 2282 - IPython.lib.backgroundjobs.__name__
2274 2283 - IPython.lib.backgroundjobs.__package__
2275 2284 - IPython.lib.backgroundjobs.__spec__
2276 2285 - IPython.lib.kernel.__builtins__
2277 2286 - IPython.lib.kernel.__cached__
2278 2287 - IPython.lib.kernel.__doc__
2279 2288 - IPython.lib.kernel.__file__
2280 2289 - IPython.lib.kernel.__loader__
2281 2290 - IPython.lib.kernel.__name__
2282 2291 - IPython.lib.kernel.__package__
2283 2292 - IPython.lib.kernel.__spec__
2284 2293 - IPython.lib.kernel.__warningregistry__
2285 2294 - IPython.paths.fs_encoding
2286 2295 - IPython.terminal.debugger.DEFAULT_BUFFER
2287 2296 - IPython.terminal.debugger.cursor_in_leading_ws
2288 2297 - IPython.terminal.debugger.emacs_insert_mode
2289 2298 - IPython.terminal.debugger.has_selection
2290 2299 - IPython.terminal.debugger.vi_insert_mode
2291 2300 - IPython.terminal.interactiveshell.DISPLAY_BANNER_DEPRECATED
2292 2301 - IPython.terminal.ipapp.TerminalIPythonApp.parse_command_line
2293 2302 - IPython.testing.test
2294 2303 - IPython.utils.contexts.NoOpContext
2295 2304 - IPython.utils.io.IOStream
2296 2305 - IPython.utils.io.IOStream.close
2297 2306 - IPython.utils.io.IOStream.write
2298 2307 - IPython.utils.io.IOStream.writelines
2299 2308 - IPython.utils.io.__warningregistry__
2300 2309 - IPython.utils.io.atomic_writing
2301 2310 - IPython.utils.io.stderr
2302 2311 - IPython.utils.io.stdin
2303 2312 - IPython.utils.io.stdout
2304 2313 - IPython.utils.io.unicode_std_stream
2305 2314 - IPython.utils.path.get_ipython_cache_dir
2306 2315 - IPython.utils.path.get_ipython_dir
2307 2316 - IPython.utils.path.get_ipython_module_path
2308 2317 - IPython.utils.path.get_ipython_package_dir
2309 2318 - IPython.utils.path.locate_profile
2310 2319 - IPython.utils.path.unquote_filename
2311 2320 - IPython.utils.py3compat.PY2
2312 2321 - IPython.utils.py3compat.PY3
2313 2322 - IPython.utils.py3compat.buffer_to_bytes
2314 2323 - IPython.utils.py3compat.builtin_mod_name
2315 2324 - IPython.utils.py3compat.cast_bytes
2316 2325 - IPython.utils.py3compat.getcwd
2317 2326 - IPython.utils.py3compat.isidentifier
2318 2327 - IPython.utils.py3compat.u_format
2319 2328
2320 2329 The following signatures differ between 7.x and 8.0::
2321 2330
2322 2331 - IPython.core.completer.IPCompleter.unicode_name_matches(self, text)
2323 2332 + IPython.core.completer.IPCompleter.unicode_name_matches(text)
2324 2333
2325 2334 - IPython.core.completer.match_dict_keys(keys, prefix, delims)
2326 2335 + IPython.core.completer.match_dict_keys(keys, prefix, delims, extra_prefix='None')
2327 2336
2328 2337 - IPython.core.interactiveshell.InteractiveShell.object_inspect_mime(self, oname, detail_level=0)
2329 2338 + IPython.core.interactiveshell.InteractiveShell.object_inspect_mime(self, oname, detail_level=0, omit_sections='()')
2330 2339
2331 2340 - IPython.core.interactiveshell.InteractiveShell.set_hook(self, name, hook, priority=50, str_key='None', re_key='None', _warn_deprecated=True)
2332 2341 + IPython.core.interactiveshell.InteractiveShell.set_hook(self, name, hook, priority=50, str_key='None', re_key='None')
2333 2342
2334 2343 - IPython.core.oinspect.Inspector.info(self, obj, oname='', formatter='None', info='None', detail_level=0)
2335 2344 + IPython.core.oinspect.Inspector.info(self, obj, oname='', info='None', detail_level=0)
2336 2345
2337 2346 - IPython.core.oinspect.Inspector.pinfo(self, obj, oname='', formatter='None', info='None', detail_level=0, enable_html_pager=True)
2338 2347 + IPython.core.oinspect.Inspector.pinfo(self, obj, oname='', formatter='None', info='None', detail_level=0, enable_html_pager=True, omit_sections='()')
2339 2348
2340 2349 - IPython.core.profiledir.ProfileDir.copy_config_file(self, config_file, path='None', overwrite=False)
2341 2350 + IPython.core.profiledir.ProfileDir.copy_config_file(self, config_file, path, overwrite=False)
2342 2351
2343 2352 - IPython.core.ultratb.VerboseTB.format_record(self, frame, file, lnum, func, lines, index)
2344 2353 + IPython.core.ultratb.VerboseTB.format_record(self, frame_info)
2345 2354
2346 2355 - IPython.terminal.embed.InteractiveShellEmbed.mainloop(self, local_ns='None', module='None', stack_depth=0, display_banner='None', global_ns='None', compile_flags='None')
2347 2356 + IPython.terminal.embed.InteractiveShellEmbed.mainloop(self, local_ns='None', module='None', stack_depth=0, compile_flags='None')
2348 2357
2349 2358 - IPython.terminal.embed.embed(**kwargs)
2350 2359 + IPython.terminal.embed.embed(*, header='', compile_flags='None', **kwargs)
2351 2360
2352 2361 - IPython.terminal.interactiveshell.TerminalInteractiveShell.interact(self, display_banner='<object object at 0xffffff>')
2353 2362 + IPython.terminal.interactiveshell.TerminalInteractiveShell.interact(self)
2354 2363
2355 2364 - IPython.terminal.interactiveshell.TerminalInteractiveShell.mainloop(self, display_banner='<object object at 0xffffff>')
2356 2365 + IPython.terminal.interactiveshell.TerminalInteractiveShell.mainloop(self)
2357 2366
2358 2367 - IPython.utils.path.get_py_filename(name, force_win32='None')
2359 2368 + IPython.utils.path.get_py_filename(name)
2360 2369
2361 2370 The following are new attributes (that might be inherited)::
2362 2371
2363 2372 + IPython.core.completer.IPCompleter.unicode_names
2364 2373 + IPython.core.debugger.InterruptiblePdb.precmd
2365 2374 + IPython.core.debugger.Pdb.precmd
2366 2375 + IPython.core.ultratb.AutoFormattedTB.has_colors
2367 2376 + IPython.core.ultratb.ColorTB.has_colors
2368 2377 + IPython.core.ultratb.FormattedTB.has_colors
2369 2378 + IPython.core.ultratb.ListTB.has_colors
2370 2379 + IPython.core.ultratb.SyntaxTB.has_colors
2371 2380 + IPython.core.ultratb.TBTools.has_colors
2372 2381 + IPython.core.ultratb.VerboseTB.has_colors
2373 2382 + IPython.terminal.debugger.TerminalPdb.do_interact
2374 2383 + IPython.terminal.debugger.TerminalPdb.precmd
2375 2384
2376 2385 The following attribute/methods have been removed::
2377 2386
2378 2387 - IPython.core.application.BaseIPythonApplication.deprecated_subcommands
2379 2388 - IPython.core.ultratb.AutoFormattedTB.format_records
2380 2389 - IPython.core.ultratb.ColorTB.format_records
2381 2390 - IPython.core.ultratb.FormattedTB.format_records
2382 2391 - IPython.terminal.embed.InteractiveShellEmbed.init_deprecation_warnings
2383 2392 - IPython.terminal.embed.InteractiveShellEmbed.init_readline
2384 2393 - IPython.terminal.embed.InteractiveShellEmbed.write
2385 2394 - IPython.terminal.embed.InteractiveShellEmbed.write_err
2386 2395 - IPython.terminal.interactiveshell.TerminalInteractiveShell.init_deprecation_warnings
2387 2396 - IPython.terminal.interactiveshell.TerminalInteractiveShell.init_readline
2388 2397 - IPython.terminal.interactiveshell.TerminalInteractiveShell.write
2389 2398 - IPython.terminal.interactiveshell.TerminalInteractiveShell.write_err
2390 2399 - IPython.terminal.ipapp.LocateIPythonApp.deprecated_subcommands
2391 2400 - IPython.terminal.ipapp.LocateIPythonApp.initialize_subcommand
2392 2401 - IPython.terminal.ipapp.TerminalIPythonApp.deprecated_subcommands
2393 2402 - IPython.terminal.ipapp.TerminalIPythonApp.initialize_subcommand
2394 2403
2395 2404 ------
2396 2405
2397 2406 .. [1] If this make you uncomfortable feel free to not use IPython 8.23.
General Comments 0
You need to be logged in to leave comments. Login now