##// END OF EJS Templates
Merge pull request #13388 from Carreau/reformat-docstring...
Matthias Bussonnier -
r27298:9065df74 merge
parent child Browse files
Show More
@@ -462,7 +462,7 b' def _deduplicate_completions(text: str, completions: _IC)-> _IC:'
462 462 seen.add(new_text)
463 463
464 464
465 def rectify_completions(text: str, completions: _IC, *, _debug=False)->_IC:
465 def rectify_completions(text: str, completions: _IC, *, _debug: bool = False) -> _IC:
466 466 """
467 467 Rectify a set of completions to all have the same ``start`` and ``end``
468 468
@@ -479,6 +479,8 b' def rectify_completions(text: str, completions: _IC, *, _debug=False)->_IC:'
479 479 text that should be completed.
480 480 completions : Iterator[Completion]
481 481 iterator over the completions to rectify
482 _debug : bool
483 Log failed completion
482 484
483 485 Notes
484 486 -----
@@ -1128,16 +1130,22 b' class IPCompleter(Completer):'
1128 1130 secondary optional dict for completions, to
1129 1131 handle cases (such as IPython embedded inside functions) where
1130 1132 both Python scopes are visible.
1131 use_readline : bool, optional
1132 DEPRECATED, ignored since IPython 6.0, will have no effects
1133 config : Config
1134 traitlet's config object
1135 **kwargs
1136 passed to super class unmodified.
1133 1137 """
1134 1138
1135 1139 self.magic_escape = ESC_MAGIC
1136 1140 self.splitter = CompletionSplitter()
1137 1141
1138 1142 # _greedy_changed() depends on splitter and readline being defined:
1139 Completer.__init__(self, namespace=namespace, global_namespace=global_namespace,
1140 config=config, **kwargs)
1143 super().__init__(
1144 namespace=namespace,
1145 global_namespace=global_namespace,
1146 config=config,
1147 **kwargs
1148 )
1141 1149
1142 1150 # List where completion matches will be stored
1143 1151 self.matches = []
@@ -2055,9 +2063,9 b' class IPCompleter(Completer):'
2055 2063
2056 2064 Parameters
2057 2065 ----------
2058 cursor_line :
2066 cursor_line
2059 2067 Index of the line the cursor is on. 0 indexed.
2060 cursor_pos :
2068 cursor_pos
2061 2069 Position of the cursor in the current line/line_buffer/text. 0
2062 2070 indexed.
2063 2071 line_buffer : optional, str
@@ -32,6 +32,8 b' from IPython.utils.py3compat import input'
32 32
33 33 from IPython.core.release import __version__ as version
34 34
35 from typing import Optional
36
35 37 #-----------------------------------------------------------------------------
36 38 # Code
37 39 #-----------------------------------------------------------------------------
@@ -95,8 +97,15 b' class CrashHandler(object):'
95 97 message_template = _default_message_template
96 98 section_sep = '\n\n'+'*'*75+'\n\n'
97 99
98 def __init__(self, app, contact_name=None, contact_email=None,
99 bug_tracker=None, show_crash_traceback=True, call_pdb=False):
100 def __init__(
101 self,
102 app,
103 contact_name: Optional[str] = None,
104 contact_email: Optional[str] = None,
105 bug_tracker: Optional[str] = None,
106 show_crash_traceback: bool = True,
107 call_pdb: bool = False,
108 ):
100 109 """Create a new crash handler
101 110
102 111 Parameters
@@ -113,10 +122,15 b' class CrashHandler(object):'
113 122 show_crash_traceback : bool
114 123 If false, don't print the crash traceback on stderr, only generate
115 124 the on-disk report
116 Non-argument instance attributes
125 call_pdb
126 Whether to call pdb on crash
127
128 Attributes
129 ----------
117 130 These instances contain some non-argument attributes which allow for
118 131 further customization of the crash handler's behavior. Please see the
119 132 source for further details.
133
120 134 """
121 135 self.crash_report_fname = "Crash_report_%s.txt" % app.name
122 136 self.app = app
@@ -798,7 +798,6 b' class Pdb(OldPdb):'
798 798
799 799 def break_anywhere(self, frame):
800 800 """
801
802 801 _stop_in_decorator_internals is overly restrictive, as we may still want
803 802 to trace function calls, so we need to also update break_anywhere so
804 803 that is we don't `stop_here`, because of debugger skip, we may still
@@ -820,8 +819,6 b' class Pdb(OldPdb):'
820 819 """
821 820 Utility to tell us whether we are in a decorator internal and should stop.
822 821
823
824
825 822 """
826 823
827 824 # if we are disabled don't skip
@@ -826,15 +826,19 b' class Image(DisplayObject):'
826 826 data : unicode, str or bytes
827 827 The raw image data or a URL or filename to load the data from.
828 828 This always results in embedded image data.
829
829 830 url : unicode
830 831 A URL to download the data from. If you specify `url=`,
831 832 the image data will not be embedded unless you also specify `embed=True`.
833
832 834 filename : unicode
833 835 Path to a local file to load the data from.
834 836 Images from a file are always embedded.
837
835 838 format : unicode
836 839 The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given
837 840 for format will be inferred from the filename extension.
841
838 842 embed : bool
839 843 Should the image data be embedded using a data URI (True) or be
840 844 loaded using an <img> tag. Set this to True if you want the image
@@ -844,10 +848,13 b' class Image(DisplayObject):'
844 848 default value is `False`.
845 849
846 850 Note that QtConsole is not able to display images if `embed` is set to `False`
851
847 852 width : int
848 853 Width in pixels to which to constrain the image in html
854
849 855 height : int
850 856 Height in pixels to which to constrain the image in html
857
851 858 retina : bool
852 859 Automatically set the width and height to half of the measured
853 860 width and height.
@@ -855,10 +862,13 b' class Image(DisplayObject):'
855 862 from image data.
856 863 For non-embedded images, you can just set the desired display width
857 864 and height directly.
865
858 866 unconfined : bool
859 867 Set unconfined=True to disable max-width confinement of the image.
868
860 869 metadata : dict
861 870 Specify extra metadata to attach to the image.
871
862 872 alt : unicode
863 873 Alternative text for the image, for use by screen readers.
864 874
@@ -1067,12 +1077,15 b' class Video(DisplayObject):'
1067 1077 data : unicode, str or bytes
1068 1078 The raw video data or a URL or filename to load the data from.
1069 1079 Raw data will require passing ``embed=True``.
1080
1070 1081 url : unicode
1071 1082 A URL for the video. If you specify ``url=``,
1072 1083 the image data will not be embedded.
1084
1073 1085 filename : unicode
1074 1086 Path to a local file containing the video.
1075 1087 Will be interpreted as a local URL unless ``embed=True``.
1088
1076 1089 embed : bool
1077 1090 Should the video be embedded using a data URI (True) or be
1078 1091 loaded using a <video> tag (False).
@@ -1083,15 +1096,19 b' class Video(DisplayObject):'
1083 1096 Local files can be displayed with URLs without embedding the content, via::
1084 1097
1085 1098 Video('./video.mp4')
1099
1086 1100 mimetype : unicode
1087 1101 Specify the mimetype for embedded videos.
1088 1102 Default will be guessed from file extension, if available.
1103
1089 1104 width : int
1090 1105 Width in pixels to which to constrain the video in HTML.
1091 1106 If not supplied, defaults to the width of the video.
1107
1092 1108 height : int
1093 1109 Height in pixels to which to constrain the video in html.
1094 1110 If not supplied, defaults to the height of the video.
1111
1095 1112 html_attributes : str
1096 1113 Attributes for the HTML ``<video>`` block.
1097 1114 Default: ``"controls"`` to get video controls.
@@ -1221,7 +1238,6 b' def set_matplotlib_close(close=True):'
1221 1238
1222 1239 use `matplotlib_inline.backend_inline.set_matplotlib_close()`
1223 1240
1224
1225 1241 Set whether the inline backend closes all figures automatically or not.
1226 1242
1227 1243 By default, the inline backend used in the IPython Notebook will close all
@@ -433,6 +433,7 b' class BaseFormatter(Configurable):'
433 433 ----------
434 434 typ : type or '__module__.__name__' string for a type
435 435 The class of the object that will be formatted using `func`.
436
436 437 func : callable
437 438 A callable for computing the format data.
438 439 `func` will be called with the object to be formatted,
@@ -474,8 +475,10 b' class BaseFormatter(Configurable):'
474 475 type_module : str
475 476 The full dotted name of the module the type is defined in, like
476 477 ``numpy``.
478
477 479 type_name : str
478 480 The name of the type (the class name), like ``dtype``
481
479 482 func : callable
480 483 A callable for computing the format data.
481 484 `func` will be called with the object to be formatted,
@@ -16,7 +16,7 b''
16 16
17 17 def get_ipython():
18 18 """Get the global InteractiveShell instance.
19
19
20 20 Returns None if no InteractiveShell instance is registered.
21 21 """
22 22 from IPython.core.interactiveshell import InteractiveShell
@@ -195,12 +195,12 b' class HistoryAccessor(HistoryAccessorBase):'
195 195 Parameters
196 196 ----------
197 197 profile : str
198 The name of the profile from which to open history.
198 The name of the profile from which to open history.
199 199 hist_file : str
200 Path to an SQLite history database stored by IPython. If specified,
201 hist_file overrides profile.
200 Path to an SQLite history database stored by IPython. If specified,
201 hist_file overrides profile.
202 202 config : :class:`~traitlets.config.loader.Config`
203 Config object. hist_file can also be set through this.
203 Config object. hist_file can also be set through this.
204 204 """
205 205 # We need a pointer back to the shell for various tasks.
206 206 super(HistoryAccessor, self).__init__(**traits)
@@ -227,7 +227,7 b' class HistoryAccessor(HistoryAccessorBase):'
227 227 Parameters
228 228 ----------
229 229 profile : str
230 The name of a profile which has a history file.
230 The name of a profile which has a history file.
231 231 """
232 232 return Path(locate_profile(profile)) / "history.sqlite"
233 233
@@ -271,13 +271,13 b' class HistoryAccessor(HistoryAccessorBase):'
271 271 Parameters
272 272 ----------
273 273 sql : str
274 Any filtering expressions to go after SELECT ... FROM ...
274 Any filtering expressions to go after SELECT ... FROM ...
275 275 params : tuple
276 Parameters passed to the SQL query (to replace "?")
276 Parameters passed to the SQL query (to replace "?")
277 277 raw, output : bool
278 See :meth:`get_range`
278 See :meth:`get_range`
279 279 latest : bool
280 Select rows with max (session, line)
280 Select rows with max (session, line)
281 281
282 282 Returns
283 283 -------
@@ -305,23 +305,21 b' class HistoryAccessor(HistoryAccessorBase):'
305 305
306 306 Parameters
307 307 ----------
308
309 308 session : int
310 309 Session number to retrieve.
311 310
312 311 Returns
313 312 -------
314
315 313 session_id : int
316 Session ID number
314 Session ID number
317 315 start : datetime
318 Timestamp for the start of the session.
316 Timestamp for the start of the session.
319 317 end : datetime
320 Timestamp for the end of the session, or None if IPython crashed.
318 Timestamp for the end of the session, or None if IPython crashed.
321 319 num_cmds : int
322 Number of commands run, or None if IPython crashed.
320 Number of commands run, or None if IPython crashed.
323 321 remark : unicode
324 A manually set description.
322 A manually set description.
325 323 """
326 324 query = "SELECT * from sessions where session == ?"
327 325 return self.db.execute(query, (session,)).fetchone()
@@ -343,13 +341,13 b' class HistoryAccessor(HistoryAccessorBase):'
343 341 Parameters
344 342 ----------
345 343 n : int
346 The number of lines to get
344 The number of lines to get
347 345 raw, output : bool
348 See :meth:`get_range`
346 See :meth:`get_range`
349 347 include_latest : bool
350 If False (default), n+1 lines are fetched, and the latest one
351 is discarded. This is intended to be used where the function
352 is called by a user command, which it should not return.
348 If False (default), n+1 lines are fetched, and the latest one
349 is discarded. This is intended to be used where the function
350 is called by a user command, which it should not return.
353 351
354 352 Returns
355 353 -------
@@ -373,16 +371,16 b' class HistoryAccessor(HistoryAccessorBase):'
373 371 Parameters
374 372 ----------
375 373 pattern : str
376 The wildcarded pattern to match when searching
374 The wildcarded pattern to match when searching
377 375 search_raw : bool
378 If True, search the raw input, otherwise, the parsed input
376 If True, search the raw input, otherwise, the parsed input
379 377 raw, output : bool
380 See :meth:`get_range`
378 See :meth:`get_range`
381 379 n : None or int
382 If an integer is given, it defines the limit of
383 returned entries.
380 If an integer is given, it defines the limit of
381 returned entries.
384 382 unique : bool
385 When it is true, return only unique entries.
383 When it is true, return only unique entries.
386 384
387 385 Returns
388 386 -------
@@ -430,9 +428,9 b' class HistoryAccessor(HistoryAccessorBase):'
430 428 Returns
431 429 -------
432 430 entries
433 An iterator over the desired lines. Each line is a 3-tuple, either
434 (session, line, input) if output is False, or
435 (session, line, (input, output)) if output is True.
431 An iterator over the desired lines. Each line is a 3-tuple, either
432 (session, line, input) if output is False, or
433 (session, line, (input, output)) if output is True.
436 434 """
437 435 if stop:
438 436 lineclause = "line >= ? AND line < ?"
@@ -451,13 +449,13 b' class HistoryAccessor(HistoryAccessorBase):'
451 449 Parameters
452 450 ----------
453 451 rangestr : str
454 A string specifying ranges, e.g. "5 ~2/1-4". If empty string is used,
455 this will return everything from current session's history.
452 A string specifying ranges, e.g. "5 ~2/1-4". If empty string is used,
453 this will return everything from current session's history.
456 454
457 See the documentation of :func:`%history` for the full details.
455 See the documentation of :func:`%history` for the full details.
458 456
459 457 raw, output : bool
460 As :meth:`get_range`
458 As :meth:`get_range`
461 459
462 460 Returns
463 461 -------
@@ -605,24 +603,22 b' class HistoryManager(HistoryAccessor):'
605 603
606 604 Parameters
607 605 ----------
608
609 606 session : int
610 607 Session number to retrieve. The current session is 0, and negative
611 608 numbers count back from current session, so -1 is the previous session.
612 609
613 610 Returns
614 611 -------
615
616 612 session_id : int
617 Session ID number
613 Session ID number
618 614 start : datetime
619 Timestamp for the start of the session.
615 Timestamp for the start of the session.
620 616 end : datetime
621 Timestamp for the end of the session, or None if IPython crashed.
617 Timestamp for the end of the session, or None if IPython crashed.
622 618 num_cmds : int
623 Number of commands run, or None if IPython crashed.
619 Number of commands run, or None if IPython crashed.
624 620 remark : unicode
625 A manually set description.
621 A manually set description.
626 622 """
627 623 if session <= 0:
628 624 session += self.session_number
@@ -673,9 +669,9 b' class HistoryManager(HistoryAccessor):'
673 669 Returns
674 670 -------
675 671 entries
676 An iterator over the desired lines. Each line is a 3-tuple, either
677 (session, line, input) if output is False, or
678 (session, line, (input, output)) if output is True.
672 An iterator over the desired lines. Each line is a 3-tuple, either
673 (session, line, input) if output is False, or
674 (session, line, (input, output)) if output is True.
679 675 """
680 676 if session <= 0:
681 677 session += self.session_number
@@ -694,14 +690,12 b' class HistoryManager(HistoryAccessor):'
694 690 Parameters
695 691 ----------
696 692 line_num : int
697 The prompt number of this input.
698
693 The prompt number of this input.
699 694 source : str
700 Python input.
701
695 Python input.
702 696 source_raw : str, optional
703 If given, this is the raw input without any IPython transformations
704 applied to it. If not given, ``source`` is used.
697 If given, this is the raw input without any IPython transformations
698 applied to it. If not given, ``source`` is used.
705 699 """
706 700 if source_raw is None:
707 701 source_raw = source
@@ -745,7 +739,7 b' class HistoryManager(HistoryAccessor):'
745 739 Parameters
746 740 ----------
747 741 line_num : int
748 The line number from which to save outputs
742 The line number from which to save outputs
749 743 """
750 744 if (not self.db_log_output) or (line_num not in self.output_hist_reprs):
751 745 return
@@ -210,7 +210,7 b' def last_blank(src):'
210 210 Parameters
211 211 ----------
212 212 src : string
213 A single or multiline string.
213 A single or multiline string.
214 214 """
215 215 if not src: return False
216 216 ll = src.splitlines()[-1]
@@ -228,7 +228,7 b' def last_two_blanks(src):'
228 228 Parameters
229 229 ----------
230 230 src : string
231 A single or multiline string.
231 A single or multiline string.
232 232 """
233 233 if not src: return False
234 234 # The logic here is tricky: I couldn't get a regexp to work and pass all
@@ -251,7 +251,7 b' def remove_comments(src):'
251 251 Parameters
252 252 ----------
253 253 src : string
254 A single or multiline input string.
254 A single or multiline input string.
255 255
256 256 Returns
257 257 -------
@@ -351,22 +351,22 b' class InputSplitter(object):'
351 351
352 352 def check_complete(self, source):
353 353 """Return whether a block of code is ready to execute, or should be continued
354
354
355 355 This is a non-stateful API, and will reset the state of this InputSplitter.
356
356
357 357 Parameters
358 358 ----------
359 359 source : string
360 Python input code, which can be multiline.
361
360 Python input code, which can be multiline.
361
362 362 Returns
363 363 -------
364 364 status : str
365 One of 'complete', 'incomplete', or 'invalid' if source is not a
366 prefix of valid code.
365 One of 'complete', 'incomplete', or 'invalid' if source is not a
366 prefix of valid code.
367 367 indent_spaces : int or None
368 The number of spaces by which to indent the next line of code. If
369 status is not 'incomplete', this is None.
368 The number of spaces by which to indent the next line of code. If
369 status is not 'incomplete', this is None.
370 370 """
371 371 self.reset()
372 372 try:
@@ -397,15 +397,15 b' class InputSplitter(object):'
397 397 Parameters
398 398 ----------
399 399 lines : string
400 One or more lines of Python input.
400 One or more lines of Python input.
401 401
402 402 Returns
403 403 -------
404 404 is_complete : boolean
405 True if the current input source (the result of the current input
406 plus prior inputs) forms a complete Python execution block. Note that
407 this value is also stored as a private attribute (``_is_complete``), so it
408 can be queried at any time.
405 True if the current input source (the result of the current input
406 plus prior inputs) forms a complete Python execution block. Note that
407 this value is also stored as a private attribute (``_is_complete``), so it
408 can be queried at any time.
409 409 """
410 410 assert isinstance(lines, str)
411 411 self._store(lines)
@@ -448,7 +448,7 b' class InputSplitter(object):'
448 448 guess whether a block is complete or not based solely on prior and
449 449 current input lines. The InputSplitter considers it has a complete
450 450 interactive block and will not accept more input when either:
451
451
452 452 * A SyntaxError is raised
453 453
454 454 * The code is complete and consists of a single line or a single
@@ -618,9 +618,9 b' class IPythonInputSplitter(InputSplitter):'
618 618 def flush_transformers(self):
619 619 def _flush(transform, outs):
620 620 """yield transformed lines
621
621
622 622 always strings, never None
623
623
624 624 transform: the current transform
625 625 outs: an iterable of previously transformed inputs.
626 626 Each may be multiline, which will be passed
@@ -690,15 +690,15 b' class IPythonInputSplitter(InputSplitter):'
690 690 Parameters
691 691 ----------
692 692 lines : string
693 One or more lines of Python input.
693 One or more lines of Python input.
694 694
695 695 Returns
696 696 -------
697 697 is_complete : boolean
698 True if the current input source (the result of the current input
699 plus prior inputs) forms a complete Python execution block. Note that
700 this value is also stored as a private attribute (_is_complete), so it
701 can be queried at any time.
698 True if the current input source (the result of the current input
699 plus prior inputs) forms a complete Python execution block. Note that
700 this value is also stored as a private attribute (_is_complete), so it
701 can be queried at any time.
702 702 """
703 703 assert isinstance(lines, str)
704 704 # We must ensure all input is pure unicode
@@ -728,10 +728,10 b' class IPythonInputSplitter(InputSplitter):'
728 728
729 729 def _transform_line(self, line):
730 730 """Push a line of input code through the various transformers.
731
731
732 732 Returns any output from the transformers, or None if a transformer
733 733 is accumulating lines.
734
734
735 735 Sets self.transformer_accumulating as a side effect.
736 736 """
737 737 def _accumulating(dbg):
@@ -46,7 +46,7 b' class InputTransformer(metaclass=abc.ABCMeta):'
46 46 def push(self, line):
47 47 """Send a line of input to the transformer, returning the transformed
48 48 input or None if the transformer is waiting for more input.
49
49
50 50 Must be overridden by subclasses.
51 51
52 52 Implementations may raise ``SyntaxError`` if the input is invalid. No
@@ -58,7 +58,7 b' class InputTransformer(metaclass=abc.ABCMeta):'
58 58 def reset(self):
59 59 """Return, transformed any lines that the transformer has accumulated,
60 60 and reset its internal state.
61
61
62 62 Must be overridden by subclasses.
63 63 """
64 64 pass
@@ -312,7 +312,7 b' def has_comment(src):'
312 312 Parameters
313 313 ----------
314 314 src : string
315 A single line input string.
315 A single line input string.
316 316
317 317 Returns
318 318 -------
@@ -324,11 +324,11 b' def has_comment(src):'
324 324 def ends_in_comment_or_string(src):
325 325 """Indicates whether or not an input line ends in a comment or within
326 326 a multiline string.
327
327
328 328 Parameters
329 329 ----------
330 330 src : string
331 A single line input string.
331 A single line input string.
332 332
333 333 Returns
334 334 -------
@@ -358,7 +358,7 b' def help_end(line):'
358 358 @CoroutineInputTransformer.wrap
359 359 def cellmagic(end_on_blank_line=False):
360 360 """Captures & transforms cell magics.
361
361
362 362 After a cell magic is started, this stores up any lines it gets until it is
363 363 reset (sent None).
364 364 """
@@ -397,7 +397,7 b' def cellmagic(end_on_blank_line=False):'
397 397
398 398 def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None):
399 399 """Remove matching input prompts from a block of input.
400
400
401 401 Parameters
402 402 ----------
403 403 prompt_re : regular expression
@@ -407,7 +407,6 b' def _strip_prompts(prompt_re, initial_re=None, turnoff_re=None):'
407 407 If no initial expression is given, prompt_re will be used everywhere.
408 408 Used mainly for plain Python prompts, where the continuation prompt
409 409 ``...`` is a valid Python expression in Python 3, so shouldn't be stripped.
410
411 410 If initial_re and prompt_re differ,
412 411 only initial_re will be tested against the first line.
413 412 If any prompt is found on the first two lines,
@@ -475,7 +474,7 b' def ipy_prompt():'
475 474 @CoroutineInputTransformer.wrap
476 475 def leading_indent():
477 476 """Remove leading indentation.
478
477
479 478 If the first line starts with a spaces or tabs, the same whitespace will be
480 479 removed from each following line until it is reset.
481 480 """
@@ -640,17 +640,17 b' class TransformerManager:'
640 640
641 641 Parameters
642 642 ----------
643 source : string
644 Python input code, which can be multiline.
643 cell : string
644 Python input code, which can be multiline.
645 645
646 646 Returns
647 647 -------
648 648 status : str
649 One of 'complete', 'incomplete', or 'invalid' if source is not a
650 prefix of valid code.
649 One of 'complete', 'incomplete', or 'invalid' if source is not a
650 prefix of valid code.
651 651 indent_spaces : int or None
652 The number of spaces by which to indent the next line of code. If
653 status is not 'incomplete', this is None.
652 The number of spaces by which to indent the next line of code. If
653 status is not 'incomplete', this is None.
654 654 """
655 655 # Remember if the lines ends in a new line.
656 656 ends_with_newline = False
@@ -1730,7 +1730,6 b' class InteractiveShell(SingletonConfigurable):'
1730 1730
1731 1731 Parameters
1732 1732 ----------
1733
1734 1733 exc_tuple : tuple of exception classes
1735 1734 A *tuple* of exception classes, for which to call the defined
1736 1735 handler. It is very important that you use a tuple, and NOT A
@@ -1760,7 +1759,6 b' class InteractiveShell(SingletonConfigurable):'
1760 1759
1761 1760 Notes
1762 1761 -----
1763
1764 1762 WARNING: by putting in your own exception handler into IPython's main
1765 1763 execution loop, you run a very good chance of nasty crashes. This
1766 1764 facility should only be used if you really know what you are doing.
@@ -1975,7 +1973,7 b' class InteractiveShell(SingletonConfigurable):'
1975 1973
1976 1974 If the syntax error occurred when running a compiled code (i.e. running_compile_code=True),
1977 1975 longer stack trace will be displayed.
1978 """
1976 """
1979 1977 etype, value, last_traceback = self._get_exc_info()
1980 1978
1981 1979 if filename and issubclass(etype, SyntaxError):
@@ -2056,26 +2054,21 b' class InteractiveShell(SingletonConfigurable):'
2056 2054
2057 2055 Parameters
2058 2056 ----------
2059
2060 text : string
2061 A string of text to be completed on. It can be given as empty and
2062 instead a line/position pair are given. In this case, the
2063 completer itself will split the line like readline does.
2064
2065 line : string, optional
2066 The complete line that text is part of.
2067
2068 cursor_pos : int, optional
2069 The position of the cursor on the input line.
2057 text : string
2058 A string of text to be completed on. It can be given as empty and
2059 instead a line/position pair are given. In this case, the
2060 completer itself will split the line like readline does.
2061 line : string, optional
2062 The complete line that text is part of.
2063 cursor_pos : int, optional
2064 The position of the cursor on the input line.
2070 2065
2071 2066 Returns
2072 2067 -------
2073 2068 text : string
2074 The actual text that was completed.
2075
2069 The actual text that was completed.
2076 2070 matches : list
2077 A sorted list with all possible completions.
2078
2071 A sorted list with all possible completions.
2079 2072
2080 2073 Notes
2081 2074 -----
@@ -2089,7 +2082,6 b' class InteractiveShell(SingletonConfigurable):'
2089 2082
2090 2083 Examples
2091 2084 --------
2092
2093 2085 In [1]: x = 'hello'
2094 2086
2095 2087 In [2]: _ip.complete('x.l')
@@ -2343,9 +2335,9 b' class InteractiveShell(SingletonConfigurable):'
2343 2335 Parameters
2344 2336 ----------
2345 2337 cmd : str
2346 Command to execute (can not end in '&', as background processes are
2347 not supported. Should not be a command that expects input
2348 other than simple text.
2338 Command to execute (can not end in '&', as background processes are
2339 not supported. Should not be a command that expects input
2340 other than simple text.
2349 2341 """
2350 2342 if cmd.rstrip().endswith('&'):
2351 2343 # this is *far* from a rigorous test
@@ -2367,7 +2359,7 b' class InteractiveShell(SingletonConfigurable):'
2367 2359 Parameters
2368 2360 ----------
2369 2361 cmd : str
2370 Command to execute.
2362 Command to execute.
2371 2363 """
2372 2364 cmd = self.var_expand(cmd, depth=1)
2373 2365 # warn if there is an IPython magic alternative.
@@ -2435,18 +2427,18 b' class InteractiveShell(SingletonConfigurable):'
2435 2427 Parameters
2436 2428 ----------
2437 2429 cmd : str
2438 Command to execute (can not end in '&', as background processes are
2439 not supported.
2430 Command to execute (can not end in '&', as background processes are
2431 not supported.
2440 2432 split : bool, optional
2441 If True, split the output into an IPython SList. Otherwise, an
2442 IPython LSString is returned. These are objects similar to normal
2443 lists and strings, with a few convenience attributes for easier
2444 manipulation of line-based output. You can use '?' on them for
2445 details.
2433 If True, split the output into an IPython SList. Otherwise, an
2434 IPython LSString is returned. These are objects similar to normal
2435 lists and strings, with a few convenience attributes for easier
2436 manipulation of line-based output. You can use '?' on them for
2437 details.
2446 2438 depth : int, optional
2447 How many frames above the caller are the local variables which should
2448 be expanded in the command string? The default (0) assumes that the
2449 expansion variables are in the stack frame calling this function.
2439 How many frames above the caller are the local variables which should
2440 be expanded in the command string? The default (0) assumes that the
2441 expansion variables are in the stack frame calling this function.
2450 2442 """
2451 2443 if cmd.rstrip().endswith('&'):
2452 2444 # this is *far* from a rigorous test
@@ -2557,9 +2549,9 b' class InteractiveShell(SingletonConfigurable):'
2557 2549 Parameters
2558 2550 ----------
2559 2551 expressions : dict
2560 A dict with string keys and string values. The expression values
2561 should be valid Python expressions, each of which will be evaluated
2562 in the user namespace.
2552 A dict with string keys and string values. The expression values
2553 should be valid Python expressions, each of which will be evaluated
2554 in the user namespace.
2563 2555
2564 2556 Returns
2565 2557 -------
@@ -2606,7 +2598,7 b' class InteractiveShell(SingletonConfigurable):'
2606 2598 ----------
2607 2599 fname : string
2608 2600 The name of the file to be executed.
2609 where : tuple
2601 *where : tuple
2610 2602 One or two namespaces, passed to execfile() as (globals,locals).
2611 2603 If only one is given, it is passed as both.
2612 2604 exit_ignore : bool (False)
@@ -2755,19 +2747,19 b' class InteractiveShell(SingletonConfigurable):'
2755 2747 Parameters
2756 2748 ----------
2757 2749 raw_cell : str
2758 The code (including IPython code such as %magic functions) to run.
2750 The code (including IPython code such as %magic functions) to run.
2759 2751 store_history : bool
2760 If True, the raw and translated cell will be stored in IPython's
2761 history. For user code calling back into IPython's machinery, this
2762 should be set to False.
2752 If True, the raw and translated cell will be stored in IPython's
2753 history. For user code calling back into IPython's machinery, this
2754 should be set to False.
2763 2755 silent : bool
2764 If True, avoid side-effects, such as implicit displayhooks and
2765 and logging. silent=True forces store_history=False.
2756 If True, avoid side-effects, such as implicit displayhooks and
2757 and logging. silent=True forces store_history=False.
2766 2758 shell_futures : bool
2767 If True, the code will share future statements with the interactive
2768 shell. It will both be affected by previous __future__ imports, and
2769 any __future__ imports in the code will affect the shell. If False,
2770 __future__ imports are not shared in either direction.
2759 If True, the code will share future statements with the interactive
2760 shell. It will both be affected by previous __future__ imports, and
2761 any __future__ imports in the code will affect the shell. If False,
2762 __future__ imports are not shared in either direction.
2771 2763
2772 2764 Returns
2773 2765 -------
@@ -2836,14 +2828,13 b' class InteractiveShell(SingletonConfigurable):'
2836 2828
2837 2829 Parameters
2838 2830 ----------
2839 raw_cell: str
2831 raw_cell : str
2840 2832 The code to be executed
2841 2833
2842 2834 Returns
2843 2835 -------
2844 2836 result: bool
2845 2837 Whether the code needs to be run with a coroutine runner or not
2846
2847 2838 .. versionadded:: 7.0
2848 2839 """
2849 2840 if not self.autoawait:
@@ -3075,8 +3066,8 b' class InteractiveShell(SingletonConfigurable):'
3075 3066 Parameters
3076 3067 ----------
3077 3068 node : ast.Node
3078 The root node to be transformed. Typically called with the ast.Module
3079 produced by parsing user input.
3069 The root node to be transformed. Typically called with the ast.Module
3070 produced by parsing user input.
3080 3071
3081 3072 Returns
3082 3073 -------
@@ -3290,17 +3281,17 b' class InteractiveShell(SingletonConfigurable):'
3290 3281
3291 3282 Parameters
3292 3283 ----------
3293 source : string
3294 Python input code, which can be multiline.
3284 code : string
3285 Python input code, which can be multiline.
3295 3286
3296 3287 Returns
3297 3288 -------
3298 3289 status : str
3299 One of 'complete', 'incomplete', or 'invalid' if source is not a
3300 prefix of valid code.
3290 One of 'complete', 'incomplete', or 'invalid' if source is not a
3291 prefix of valid code.
3301 3292 indent : str
3302 When status is 'incomplete', this is some whitespace to insert on
3303 the next line of the prompt.
3293 When status is 'incomplete', this is some whitespace to insert on
3294 the next line of the prompt.
3304 3295 """
3305 3296 status, nspaces = self.input_transformer_manager.check_complete(code)
3306 3297 return status, ' ' * (nspaces or 0)
@@ -3327,13 +3318,13 b' class InteractiveShell(SingletonConfigurable):'
3327 3318 Parameters
3328 3319 ----------
3329 3320 gui : optional, string
3330 If given, dictates the choice of matplotlib GUI backend to use
3331 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3332 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3333 matplotlib (as dictated by the matplotlib build-time options plus the
3334 user's matplotlibrc configuration file). Note that not all backends
3335 make sense in all contexts, for example a terminal ipython can't
3336 display figures inline.
3321 If given, dictates the choice of matplotlib GUI backend to use
3322 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3323 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3324 matplotlib (as dictated by the matplotlib build-time options plus the
3325 user's matplotlibrc configuration file). Note that not all backends
3326 make sense in all contexts, for example a terminal ipython can't
3327 display figures inline.
3337 3328 """
3338 3329 from IPython.core import pylabtools as pt
3339 3330 from matplotlib_inline.backend_inline import configure_inline_support
@@ -3373,18 +3364,18 b' class InteractiveShell(SingletonConfigurable):'
3373 3364 Parameters
3374 3365 ----------
3375 3366 gui : optional, string
3376 If given, dictates the choice of matplotlib GUI backend to use
3377 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3378 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3379 matplotlib (as dictated by the matplotlib build-time options plus the
3380 user's matplotlibrc configuration file). Note that not all backends
3381 make sense in all contexts, for example a terminal ipython can't
3382 display figures inline.
3367 If given, dictates the choice of matplotlib GUI backend to use
3368 (should be one of IPython's supported backends, 'qt', 'osx', 'tk',
3369 'gtk', 'wx' or 'inline'), otherwise we use the default chosen by
3370 matplotlib (as dictated by the matplotlib build-time options plus the
3371 user's matplotlibrc configuration file). Note that not all backends
3372 make sense in all contexts, for example a terminal ipython can't
3373 display figures inline.
3383 3374 import_all : optional, bool, default: True
3384 Whether to do `from numpy import *` and `from pylab import *`
3385 in addition to module imports.
3375 Whether to do `from numpy import *` and `from pylab import *`
3376 in addition to module imports.
3386 3377 welcome_message : deprecated
3387 This argument is ignored, no welcome message will be displayed.
3378 This argument is ignored, no welcome message will be displayed.
3388 3379 """
3389 3380 from IPython.core.pylabtools import import_pylab
3390 3381
@@ -3491,7 +3482,6 b' class InteractiveShell(SingletonConfigurable):'
3491 3482
3492 3483 Notes
3493 3484 -----
3494
3495 3485 Slices can be described with two notations:
3496 3486
3497 3487 * ``N:M`` -> standard python form, means including items N...(M-1).
@@ -3517,26 +3507,25 b' class InteractiveShell(SingletonConfigurable):'
3517 3507 Parameters
3518 3508 ----------
3519 3509 target : str
3520 A string specifying code to retrieve. This will be tried respectively
3521 as: ranges of input history (see %history for syntax), url,
3522 corresponding .py file, filename, or an expression evaluating to a
3523 string or Macro in the user namespace.
3510 A string specifying code to retrieve. This will be tried respectively
3511 as: ranges of input history (see %history for syntax), url,
3512 corresponding .py file, filename, or an expression evaluating to a
3513 string or Macro in the user namespace.
3524 3514
3525 If empty string is given, returns complete history of current
3526 session, without the last line.
3515 If empty string is given, returns complete history of current
3516 session, without the last line.
3527 3517
3528 3518 raw : bool
3529 If true (default), retrieve raw history. Has no effect on the other
3530 retrieval mechanisms.
3519 If true (default), retrieve raw history. Has no effect on the other
3520 retrieval mechanisms.
3531 3521
3532 3522 py_only : bool (default False)
3533 Only try to fetch python code, do not try alternative methods to decode file
3534 if unicode fails.
3523 Only try to fetch python code, do not try alternative methods to decode file
3524 if unicode fails.
3535 3525
3536 3526 Returns
3537 3527 -------
3538 3528 A string of code.
3539
3540 3529 ValueError is raised if nothing is found, and TypeError if it evaluates
3541 3530 to an object of another type. In each case, .args[0] is a printable
3542 3531 message.
@@ -114,16 +114,13 b' def record_magic(dct, magic_kind, magic_name, func):'
114 114 Parameters
115 115 ----------
116 116 dct : dict
117 A dictionary with 'line' and 'cell' subdicts.
118
117 A dictionary with 'line' and 'cell' subdicts.
119 118 magic_kind : str
120 Kind of magic to be stored.
121
119 Kind of magic to be stored.
122 120 magic_name : str
123 Key to store the magic as.
124
121 Key to store the magic as.
125 122 func : function
126 Callable object to store.
123 Callable object to store.
127 124 """
128 125 if magic_kind == 'line_cell':
129 126 dct['line'][magic_name] = dct['cell'][magic_name] = func
@@ -372,7 +369,7 b' class MagicsManager(Configurable):'
372 369 def register(self, *magic_objects):
373 370 """Register one or more instances of Magics.
374 371
375 Take one or more classes or instances of classes that subclass the main
372 Take one or more classes or instances of classes that subclass the main
376 373 `core.Magic` class, and register them with IPython to use the magic
377 374 functions they provide. The registration process will then ensure that
378 375 any methods that have decorated to provide line and/or cell magics will
@@ -387,7 +384,7 b' class MagicsManager(Configurable):'
387 384
388 385 Parameters
389 386 ----------
390 magic_objects : one or more classes or instances
387 *magic_objects : one or more classes or instances
391 388 """
392 389 # Start by validating them to ensure they have all had their magic
393 390 # methods registered at the instance level
@@ -410,7 +407,7 b' class MagicsManager(Configurable):'
410 407
411 408 This will create an IPython magic (line, cell or both) from a
412 409 standalone function. The functions should have the following
413 signatures:
410 signatures:
414 411
415 412 * For line magics: `def f(line)`
416 413 * For cell magics: `def f(line, cell)`
@@ -422,14 +419,12 b' class MagicsManager(Configurable):'
422 419 Parameters
423 420 ----------
424 421 func : callable
425 Function to be registered as a magic.
426
422 Function to be registered as a magic.
427 423 magic_kind : str
428 Kind of magic, one of 'line', 'cell' or 'line_cell'
429
424 Kind of magic, one of 'line', 'cell' or 'line_cell'
430 425 magic_name : optional str
431 If given, the name the magic will have in the IPython namespace. By
432 default, the name of the function itself is used.
426 If given, the name the magic will have in the IPython namespace. By
427 default, the name of the function itself is used.
433 428 """
434 429
435 430 # Create the new method in the user_magics and register it in the
@@ -450,13 +445,11 b' class MagicsManager(Configurable):'
450 445 Parameters
451 446 ----------
452 447 alias_name : str
453 The name of the magic to be registered.
454
448 The name of the magic to be registered.
455 449 magic_name : str
456 The name of an existing magic.
457
450 The name of an existing magic.
458 451 magic_kind : str
459 Kind of magic, one of 'line' or 'cell'
452 Kind of magic, one of 'line' or 'cell'
460 453 """
461 454
462 455 # `validate_type` is too permissive, as it allows 'line_cell'
@@ -580,25 +573,20 b' class Magics(Configurable):'
580 573
581 574 Parameters
582 575 ----------
583
584 576 arg_str : str
585 The arguments to parse.
586
577 The arguments to parse.
587 578 opt_str : str
588 The options specification.
589
579 The options specification.
590 580 mode : str, default 'string'
591 If given as 'list', the argument string is returned as a list (split
592 on whitespace) instead of a string.
593
581 If given as 'list', the argument string is returned as a list (split
582 on whitespace) instead of a string.
594 583 list_all : bool, default False
595 Put all option values in lists. Normally only options
596 appearing more than once are put in a list.
597
584 Put all option values in lists. Normally only options
585 appearing more than once are put in a list.
598 586 posix : bool, default True
599 Whether to split the input line in POSIX mode or not, as per the
600 conventions outlined in the :mod:`shlex` module from the standard
601 library.
587 Whether to split the input line in POSIX mode or not, as per the
588 conventions outlined in the :mod:`shlex` module from the standard
589 library.
602 590 """
603 591
604 592 # inject default options at the beginning of the input line
@@ -46,7 +46,7 b' class MagicsDisplay(object):'
46 46
47 47 def _jsonable(self):
48 48 """turn magics dict into jsonable dict of the same structure
49
49
50 50 replaces object instances with their class names as strings
51 51 """
52 52 magic_dict = {}
@@ -124,7 +124,7 b' class BasicMagics(Magics):'
124 124
125 125 In [6]: %whereami
126 126 Out[6]: u'/home/testuser'
127
127
128 128 In [7]: %alias_magic h history "-p -l 30" --line
129 129 Created `%h` as an alias for `%history -l 30`.
130 130 """
@@ -368,7 +368,7 b' Currently the magic system has the following functions:""",'
368 368
369 369 If called without arguments, acts as a toggle.
370 370
371 When in verbose mode the value --show (and --hide)
371 When in verbose mode the value --show (and --hide)
372 372 will respectively show (or hide) frames with ``__tracebackhide__ =
373 373 True`` value set.
374 374 """
@@ -618,12 +618,11 b' class AsyncMagics(BasicMagics):'
618 618
619 619 If the passed parameter does not match any of the above and is a python
620 620 identifier, get said object from user namespace and set it as the
621 runner, and activate autoawait.
621 runner, and activate autoawait.
622 622
623 623 If the object is a fully qualified object name, attempt to import it and
624 624 set it as the runner, and activate autoawait.
625
626
625
627 626 The exact behavior of autoawait is experimental and subject to change
628 627 across version of IPython and Python.
629 628 """
@@ -1067,7 +1067,6 b' class ExecutionMagics(Magics):'
1067 1067
1068 1068 In [6]: %timeit -n1 time.sleep(2)
1069 1069
1070
1071 1070 The times reported by %timeit will be slightly higher than those
1072 1071 reported by the timeit.py script when variables are accessed. This is
1073 1072 due to the fact that %timeit executes the statement in the namespace
@@ -1201,7 +1200,7 b' class ExecutionMagics(Magics):'
1201 1200 The CPU and wall clock times are printed, and the value of the
1202 1201 expression (if any) is returned. Note that under Win32, system time
1203 1202 is always reported as 0, since it can not be measured.
1204
1203
1205 1204 This function can be used both as a line and cell magic:
1206 1205
1207 1206 - In line mode you can time a single-line statement (though multiple
@@ -1238,7 +1237,6 b' class ExecutionMagics(Magics):'
1238 1237 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1239 1238 Wall time: 0.00
1240 1239
1241
1242 1240 .. note::
1243 1241 The time needed by Python to compile the given expression will be
1244 1242 reported if it is more than 0.1s.
@@ -41,7 +41,7 b' class ExtensionMagics(Magics):'
41 41 @line_magic
42 42 def unload_ext(self, module_str):
43 43 """Unload an IPython extension by its module name.
44
44
45 45 Not all extensions can be unloaded, only those which define an
46 46 ``unload_ipython_extension`` function.
47 47 """
@@ -105,7 +105,7 b' class HistoryMagics(Magics):'
105 105
106 106 By default, all input history from the current session is displayed.
107 107 Ranges of history can be indicated using the syntax:
108
108
109 109 ``4``
110 110 Line 4, current session
111 111 ``4-6``
@@ -117,7 +117,7 b' class HistoryMagics(Magics):'
117 117 ``~8/1-~6/5``
118 118 From the first line of 8 sessions ago, to the fifth line of 6
119 119 sessions ago.
120
120
121 121 Multiple ranges can be entered, separated by spaces
122 122
123 123 The same syntax is used by %macro, %save, %edit, %rerun
@@ -173,7 +173,7 b' class NamespaceMagics(Magics):'
173 173 'builtin', 'user', 'user_global','internal', 'alias', where
174 174 'builtin' and 'user' are the search defaults. Note that you should
175 175 not use quotes when specifying namespaces.
176
176
177 177 -l: List all available object types for object matching. This function
178 178 can be used without arguments.
179 179
@@ -203,9 +203,9 b' class NamespaceMagics(Magics):'
203 203 Show objects beginning with a single _::
204 204
205 205 %psearch -a _* list objects beginning with a single underscore
206
206
207 207 List available objects::
208
208
209 209 %psearch -l list all available object types
210 210 """
211 211 # default namespaces to be searched
@@ -252,7 +252,6 b' class NamespaceMagics(Magics):'
252 252
253 253 Examples
254 254 --------
255
256 255 Define two variables and list them with who_ls::
257 256
258 257 In [1]: alpha = 123
@@ -367,7 +366,6 b' class NamespaceMagics(Magics):'
367 366
368 367 Examples
369 368 --------
370
371 369 Define two variables and list them with whos::
372 370
373 371 In [1]: alpha = 123
@@ -484,23 +482,21 b' class NamespaceMagics(Magics):'
484 482
485 483 Parameters
486 484 ----------
487 -f : force reset without asking for confirmation.
488
489 -s : 'Soft' reset: Only clears your namespace, leaving history intact.
485 -f
486 force reset without asking for confirmation.
487 -s
488 'Soft' reset: Only clears your namespace, leaving history intact.
490 489 References to objects may be kept. By default (without this option),
491 490 we do a 'hard' reset, giving you a new session and removing all
492 491 references to objects from the current session.
493
494 --aggressive: Try to aggressively remove modules from sys.modules ; this
492 --aggressive
493 Try to aggressively remove modules from sys.modules ; this
495 494 may allow you to reimport Python modules that have been updated and
496 495 pick up changes, but can have unattended consequences.
497 496
498 497 in : reset input history
499
500 498 out : reset output history
501
502 499 dhist : reset directory history
503
504 500 array : reset only variables that are NumPy arrays
505 501
506 502 See Also
@@ -624,7 +620,6 b' class NamespaceMagics(Magics):'
624 620
625 621 Examples
626 622 --------
627
628 623 We first fully reset the namespace so your output looks identical to
629 624 this example for pedagogical reasons; in practice you do not need a
630 625 full reset::
@@ -65,7 +65,7 b' class OSMagics(Magics):'
65 65
66 66 def _isexec_POSIX(self, file):
67 67 """
68 Test for executable on a POSIX system
68 Test for executable on a POSIX system
69 69 """
70 70 if os.access(file.path, os.X_OK):
71 71 # will fail on maxOS if access is not X_OK
@@ -76,13 +76,13 b' class OSMagics(Magics):'
76 76
77 77 def _isexec_WIN(self, file):
78 78 """
79 Test for executable file on non POSIX system
79 Test for executable file on non POSIX system
80 80 """
81 81 return file.is_file() and self.execre.match(file.name) is not None
82 82
83 83 def isexec(self, file):
84 84 """
85 Test for executable file on non POSIX system
85 Test for executable file on non POSIX system
86 86 """
87 87 if self.is_posix:
88 88 return self._isexec_POSIX(file)
@@ -316,7 +316,6 b' class OSMagics(Magics):'
316 316 ``cd <bookmark_name>`` is enough if there is no directory
317 317 ``<bookmark_name>``, but a bookmark with the name exists.
318 318
319
320 319 Options:
321 320
322 321 -q Be quiet. Do not print the working directory after the
@@ -329,7 +328,6 b' class OSMagics(Magics):'
329 328 where ``!command`` runs is immediately discarded after executing
330 329 'command'.
331 330
332
333 331 Examples
334 332 --------
335 333 ::
@@ -834,7 +832,7 b' class OSMagics(Magics):'
834 832 @cell_magic
835 833 def writefile(self, line, cell):
836 834 """Write the contents of the cell to a file.
837
835
838 836 The file will be overwritten unless the -a (--append) flag is specified.
839 837 """
840 838 args = magic_arguments.parse_argstring(self.writefile, line)
@@ -202,16 +202,16 b' class ScriptMagics(Magics):'
202 202 @dec_safe_watcher
203 203 def shebang(self, line, cell):
204 204 """Run a cell via a shell command
205
205
206 206 The `%%script` line is like the #! line of script,
207 207 specifying a program (bash, perl, ruby, etc.) with which to run.
208
208
209 209 The rest of the cell is run by that program.
210
210
211 211 Examples
212 212 --------
213 213 ::
214
214
215 215 In [1]: %%script bash
216 216 ...: for i in 1 2 3; do
217 217 ...: echo $i
@@ -302,7 +302,7 b' def find_file(obj) -> str:'
302 302 Returns
303 303 -------
304 304 fname : str
305 The absolute path to the file where the object was defined.
305 The absolute path to the file where the object was defined.
306 306 """
307 307 obj = _get_wrapped(obj)
308 308
@@ -337,7 +337,7 b' def find_source_lines(obj):'
337 337 Returns
338 338 -------
339 339 lineno : int
340 The line number where the object definition starts.
340 The line number where the object definition starts.
341 341 """
342 342 obj = _get_wrapped(obj)
343 343
@@ -428,7 +428,6 b' class Inspector(Colorable):'
428 428
429 429 Examples
430 430 --------
431
432 431 In [1]: class NoInit:
433 432 ...: pass
434 433
@@ -575,18 +574,17 b' class Inspector(Colorable):'
575 574 """Retrieve an info dict and format it.
576 575
577 576 Parameters
578 ==========
579
580 obj: any
577 ----------
578 obj : any
581 579 Object to inspect and return info from
582 580 oname: str (default: ''):
583 581 Name of the variable pointing to `obj`.
584 formatter: callable
582 formatter : callable
585 583 info:
586 584 already computed information
587 detail_level: integer
585 detail_level : integer
588 586 Granularity of detail level, if set to 1, give more information.
589 omit_sections: container[str]
587 omit_sections : container[str]
590 588 Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
591 589 """
592 590
@@ -716,21 +714,19 b' class Inspector(Colorable):'
716 714 """Compute a dict with detailed information about an object.
717 715
718 716 Parameters
719 ==========
720
721 obj: any
717 ----------
718 obj : any
722 719 An object to find information about
723 oname: str (default: ''):
720 oname : str (default: '')
724 721 Name of the variable pointing to `obj`.
725 info: (default: None)
722 info : (default: None)
726 723 A struct (dict like with attr access) with some information fields
727 724 which may have been precomputed already.
728 detail_level: int (default:0)
725 detail_level : int (default:0)
729 726 If set to 1, more information is given.
730 727
731 728 Returns
732 =======
733
729 -------
734 730 An object info dict with known fields from `info_fields`. Keys are
735 731 strings, values are string or None.
736 732 """
@@ -962,7 +958,7 b' class Inspector(Colorable):'
962 958
963 959 - show_all(False): show all names, including those starting with
964 960 underscores.
965
961
966 962 - list_types(False): list all available object types for object matching.
967 963 """
968 964 #print 'ps pattern:<%r>' % pattern # dbg
@@ -46,7 +46,7 b' def display_page(strng, start=0, screen_lines=25):'
46 46
47 47 def as_hook(page_func):
48 48 """Wrap a pager func to strip the `self` arg
49
49
50 50 so it can be called as a hook.
51 51 """
52 52 return lambda self, *args, **kwargs: page_func(*args, **kwargs)
@@ -127,7 +127,7 b' def _detect_screen_size(screen_lines_def):'
127 127
128 128 def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):
129 129 """Display a string, piping through a pager after a certain length.
130
130
131 131 strng can be a mime-bundle dict, supplying multiple representations,
132 132 keyed by mime-type.
133 133
@@ -238,10 +238,10 b' def pager_page(strng, start=0, screen_lines=0, pager_cmd=None):'
238 238
239 239 def page(data, start=0, screen_lines=0, pager_cmd=None):
240 240 """Display content in a pager, piping through a pager after a certain length.
241
241
242 242 data can be a mime-bundle dict, supplying multiple representations,
243 243 keyed by mime-type, or text.
244
244
245 245 Pager is dispatched via the `show_in_pager` IPython hook.
246 246 If no hook is registered, `pager_page` will be used.
247 247 """
@@ -17,10 +17,9 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
17 17 Parameters
18 18 ----------
19 19 strng : str or mime-dict
20 Text to page, or a mime-type keyed dict of already formatted data.
21
20 Text to page, or a mime-type keyed dict of already formatted data.
22 21 start : int
23 Starting line at which to place the display.
22 Starting line at which to place the display.
24 23 """
25 24
26 25 # Some routines may auto-compute start offsets incorrectly and pass a
@@ -42,7 +41,7 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):'
42 41
43 42 def install_payload_page():
44 43 """DEPRECATED, use show_in_pager hook
45
44
46 45 Install this version of page as IPython.core.page.page.
47 46 """
48 47 warnings.warn("""install_payload_page is deprecated.
@@ -185,8 +185,8 b' def mpl_runner(safe_execfile):'
185 185 Parameters
186 186 ----------
187 187 safe_execfile : function
188 This must be a function with the same interface as the
189 :meth:`safe_execfile` method of IPython.
188 This must be a function with the same interface as the
189 :meth:`safe_execfile` method of IPython.
190 190
191 191 Returns
192 192 -------
@@ -241,7 +241,7 b' def select_figure_formats(shell, formats, **kwargs):'
241 241 """Select figure formats for the inline backend.
242 242
243 243 Parameters
244 ==========
244 ----------
245 245 shell : InteractiveShell
246 246 The main IPython instance.
247 247 formats : str or set
@@ -408,7 +408,6 b' def configure_inline_support(shell, backend):'
408 408 Parameters
409 409 ----------
410 410 shell : InteractiveShell instance
411
412 411 backend : matplotlib backend
413 412 """
414 413 warnings.warn(
@@ -556,7 +556,7 b' class ListTB(TBTools):'
556 556 Parameters
557 557 ----------
558 558 etype : exception type
559 evalue : exception value
559 value : exception value
560 560 """
561 561 return ListTB.structured_traceback(self, etype, value)
562 562
@@ -75,7 +75,7 b' sys.meta_path.insert(0, ID)'
75 75
76 76 def commit_api(api):
77 77 """Commit to a particular API, and trigger ImportErrors on subsequent
78 dangerous imports"""
78 dangerous imports"""
79 79 modules = set(api_to_module.values())
80 80
81 81 modules.remove(api_to_module[api])
@@ -115,15 +115,15 b' def loaded_api():'
115 115 def has_binding(api):
116 116 """Safely check for PyQt4/5, PySide or PySide2, without importing submodules
117 117
118 Parameters
119 ----------
120 api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
121 Which module to check for
118 Parameters
119 ----------
120 api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
121 Which module to check for
122 122
123 Returns
124 -------
125 True if the relevant module appears to be importable
126 """
123 Returns
124 -------
125 True if the relevant module appears to be importable
126 """
127 127 module_name = api_to_module[api]
128 128 from importlib.util import find_spec
129 129
@@ -193,9 +193,8 b' def import_pyqt4(version=2):'
193 193 Parameters
194 194 ----------
195 195 version : 1, 2, or None
196 Which QString/QVariant API to use. Set to None to use the system
197 default
198
196 Which QString/QVariant API to use. Set to None to use the system
197 default
199 198 ImportErrors raised within this function are non-recoverable
200 199 """
201 200 # The new-style string API (version=2) automatically
@@ -319,13 +318,12 b' def load_qt(api_options):'
319 318
320 319 Parameters
321 320 ----------
322 api_options: List of strings
321 api_options : List of strings
323 322 The order of APIs to try. Valid items are 'pyside', 'pyside2',
324 323 'pyqt', 'pyqt5', 'pyqtv1' and 'pyqtdefault'
325 324
326 325 Returns
327 326 -------
328
329 327 A tuple of QtCore, QtGui, QtSvg, QT_API
330 328 The first three are the Qt modules. The last is the
331 329 string indicating which module was loaded.
@@ -116,7 +116,7 b' class BackgroundJobManager(object):'
116 116 The given expression is passed to eval(), along with the optional
117 117 global/local dicts provided. If no dicts are given, they are
118 118 extracted automatically from the caller's frame.
119
119
120 120 A Python statement is NOT a valid eval() expression. Basically, you
121 121 can only use as an eval() argument something which can go on the right
122 122 of an '=' sign and be assigned to a variable.
@@ -239,7 +239,7 b' class Demo(object):'
239 239 terminal16m
240 240
241 241 - style('default'): a string of pygments style name to be used.
242 """
242 """
243 243 if hasattr(src, "read"):
244 244 # It seems to be a file or a file-like object
245 245 self.fname = "from a file-like object"
@@ -517,20 +517,20 b' class FileLinks(FileLink):'
517 517 fp_cleaner=None):
518 518 """ generate built-in formatter function
519 519
520 this is used to define both the notebook and terminal built-in
521 formatters as they only differ by some wrapper text for each entry
522
523 dirname_output_format: string to use for formatting directory
524 names, dirname will be substituted for a single "%s" which
525 must appear in this string
526 fname_output_format: string to use for formatting file names,
527 if a single "%s" appears in the string, fname will be substituted
528 if two "%s" appear in the string, the path to fname will be
529 substituted for the first and fname will be substituted for the
530 second
531 fp_format: string to use for formatting filepaths, must contain
532 exactly two "%s" and the dirname will be substituted for the first
533 and fname will be substituted for the second
520 this is used to define both the notebook and terminal built-in
521 formatters as they only differ by some wrapper text for each entry
522
523 dirname_output_format: string to use for formatting directory
524 names, dirname will be substituted for a single "%s" which
525 must appear in this string
526 fname_output_format: string to use for formatting file names,
527 if a single "%s" appears in the string, fname will be substituted
528 if two "%s" appear in the string, the path to fname will be
529 substituted for the first and fname will be substituted for the
530 second
531 fp_format: string to use for formatting filepaths, must contain
532 exactly two "%s" and the dirname will be substituted for the first
533 and fname will be substituted for the second
534 534 """
535 535 def f(dirname, fnames, included_suffixes=None):
536 536 result = []
@@ -77,7 +77,6 b" def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black',"
77 77 format, e.g. '#AA20FA'.
78 78 scale : float
79 79 Scale factor for the resulting PNG.
80
81 80 None is returned when the backend cannot be used.
82 81
83 82 """
@@ -49,7 +49,6 b' class EmbeddedMagics(Magics):'
49 49 you may then kill it and the program will then continue to run without
50 50 the interactive shell interfering again.
51 51
52
53 52 Kill Instance Option:
54 53
55 54 If for some reasons you need to kill the location where the instance
@@ -266,25 +265,21 b' class InteractiveShellEmbed(TerminalInteractiveShell):'
266 265
267 266 Parameters
268 267 ----------
269
270
271 268 local_ns, module
272 Working local namespace (a dict) and module (a module or similar
273 object). If given as None, they are automatically taken from the scope
274 where the shell was called, so that program variables become visible.
275
269 Working local namespace (a dict) and module (a module or similar
270 object). If given as None, they are automatically taken from the scope
271 where the shell was called, so that program variables become visible.
276 272 stack_depth : int
277 How many levels in the stack to go to looking for namespaces (when
278 local_ns or module is None). This allows an intermediate caller to
279 make sure that this function gets the namespace from the intended
280 level in the stack. By default (0) it will get its locals and globals
281 from the immediate caller.
282
273 How many levels in the stack to go to looking for namespaces (when
274 local_ns or module is None). This allows an intermediate caller to
275 make sure that this function gets the namespace from the intended
276 level in the stack. By default (0) it will get its locals and globals
277 from the immediate caller.
283 278 compile_flags
284 A bit field identifying the __future__ features
285 that are enabled, as passed to the builtin :func:`compile` function.
286 If given as None, they are automatically taken from the scope where
287 the shell was called.
279 A bit field identifying the __future__ features
280 that are enabled, as passed to the builtin :func:`compile` function.
281 If given as None, they are automatically taken from the scope where
282 the shell was called.
288 283
289 284 """
290 285
@@ -113,9 +113,9 b' class TerminalMagics(Magics):'
113 113
114 114 Shell escapes are not supported (yet).
115 115
116 See also
116 See Also
117 117 --------
118 paste: automatically pull code from clipboard.
118 paste : automatically pull code from clipboard.
119 119
120 120 Examples
121 121 --------
@@ -176,9 +176,9 b' class TerminalMagics(Magics):'
176 176
177 177 IPython statements (magics, shell escapes) are not supported (yet).
178 178
179 See also
179 See Also
180 180 --------
181 cpaste: manually paste code into terminal until you mark its end.
181 cpaste : manually paste code into terminal until you mark its end.
182 182 """
183 183 opts, name = self.parse_options(parameter_s, 'rq', mode='string')
184 184 if 'r' in opts:
@@ -22,12 +22,24 b' Need to be updated:'
22 22
23 23 pr/*
24 24
25 IPython 8.0 is bringing a number of new features and improvements to both the
25 IPython 8.0 is bringing a large number of new features and improvements to both the
26 26 user of the terminal and of the kernel via Jupyter. The removal of compatibility
27 27 with older version of Python is also the opportunity to do a couple of
28 28 performance improvement in particular with respect to startup time.
29 29
30 The main change in IPython 8.0 is the integration of the ``stack_data`` package;
30 This release contains 250+ Pull requests, in addition to many of the features
31 and backports that have made it to the 7.x branch.
32
33 We removed almost all features, arguments, functions, and modules that were
34 marked as deprecated between IPython 1.0 and 5.0 and before. As reminder 5.0 was
35 released in 2016, and 1.0 in 2013. Last release of the 5 branch was 5.10.0, in
36 may 2020. The few remaining deprecated features have better deprecation warnings
37 or errors.
38
39 There are many change in IPython 8.0 will will try to describe subsequently,
40
41
42 The first on is the integration of the ``stack_data`` package;
31 43 which provide smarter information in traceback; in particular it will highlight
32 44 the AST node where an error occurs which can help to quickly narrow down errors.
33 45
@@ -50,13 +62,34 b' IPython 8.0 is capable of telling you, where the index error occurs::'
50 62 return x[0][i][0]
51 63 ^
52 64
65
66 Numfocus Small Developer Grant
67 ------------------------------
68
53 69 To prepare for Python 3.10 we have also started working on removing reliance and
54 70 any dependency that is not Python 3.10 compatible; that include migrating our
55 test suite to Pytest, and starting to remove nose.
71 test suite to pytest, and starting to remove nose. This also mean that the
72 ``iptest`` command is now gone, and all testing is via pytest.
73
74 This was in bog part thanks the NumFOCUS Small Developer grant, we were able to
75 allocate 4000 to hire `Nikita Kniazev @Kojoley <https://github.com/Kojoley>`__
76 who did a fantastic job at updating our code base, migrating to pytest, pushing
77 our coverage, and fixing a large number of bugs. I highly recommend contacting
78 them if you need help with C++ and Python projects
56 79
57 We are also removing support for Python 3.6 allowing internal code to use more
80 You can find all relevant issues and PRs with the SDG 2021 tag:
81
82 https://github.com/ipython/ipython/issues?q=label%3A%22Numfocus+SDG+2021%22+
83
84 Removing support for Older Python
85 ---------------------------------
86
87
88 We are also removing support for Python up to 3.7 allowing internal code to use more
58 89 efficient ``pathlib``, and make better use of type annotations.
59 90
91 IMAGE : Pathlib, pathlib everywhere.
92
60 93 The completer has also seen significant updates and make use of newer Jedi API
61 94 offering faster and more reliable tab completion.
62 95
@@ -168,7 +201,154 b' Try ``%autoreload 3`` in an IPython session after running ``%load_ext autoreload'
168 201 For more information please see unit test -
169 202 extensions/tests/test_autoreload.py : 'test_autoload_newly_added_objects'
170 203
171 =======
204
205 Miscelanious
206 ------------
207
208 Minimum supported
209
210
211 History Range Glob feature
212 ==========================
213
214 Previously, when using ``%history``, users could specify either
215 a range of sessions and lines, for example:
216
217 .. code-block:: python
218
219 ~8/1-~6/5 # see history from the first line of 8 sessions ago,
220 # to the fifth line of 6 sessions ago.``
221
222 Or users could specify a glob pattern:
223
224 .. code-block:: python
225
226 -g <pattern> # glob ALL history for the specified pattern.
227
228 However users could *not* specify both.
229
230 If a user *did* specify both a range and a glob pattern,
231 then the glob pattern would be used (globbing *all* history) *and the range would be ignored*.
232
233 ---
234
235 With this enhancement, if a user specifies both a range and a glob pattern, then the glob pattern will be applied to the specified range of history.
236
237 Don't start a multi line cell with sunken parenthesis
238 -----------------------------------------------------
239
240 From now on IPython will not ask for the next line of input when given a single
241 line with more closing than opening brackets. For example, this means that if
242 you (mis)type ']]' instead of '[]', a ``SyntaxError`` will show up, instead of
243 the ``...:`` prompt continuation.
244
245 IPython shell for ipdb interact
246 -------------------------------
247
248 The ipdb ``interact`` starts an IPython shell instead of Python's built-in ``code.interact()``.
249
250 Automatic Vi prompt stripping
251 =============================
252
253 When pasting code into IPython, it will strip the leading prompt characters if
254 there are any. For example, you can paste the following code into the console -
255 it will still work, even though each line is prefixed with prompts (`In`,
256 `Out`)::
257
258 In [1]: 2 * 2 == 4
259 Out[1]: True
260
261 In [2]: print("This still works as pasted")
262
263
264 Previously, this was not the case for the Vi-mode prompts::
265
266 In [1]: [ins] In [13]: 2 * 2 == 4
267 ...: Out[13]: True
268 ...:
269 File "<ipython-input-1-727bb88eaf33>", line 1
270 [ins] In [13]: 2 * 2 == 4
271 ^
272 SyntaxError: invalid syntax
273
274 This is now fixed, and Vi prompt prefixes - ``[ins]`` and ``[nav]`` - are
275 skipped just as the normal ``In`` would be.
276
277 IPython shell can be started in the Vi mode using ``ipython
278 --TerminalInteractiveShell.editing_mode=vi``
279
280 Empty History Ranges
281 ====================
282
283 A number of magics that take history ranges can now be used with an empty
284 range. These magics are:
285
286 * ``%save``
287 * ``%load``
288 * ``%pastebin``
289 * ``%pycat``
290
291 Using them this way will make them take the history of the current session up
292 to the point of the magic call (such that the magic itself will not be
293 included).
294
295 Therefore it is now possible to save the whole history to a file using simple
296 ``%save <filename>``, load and edit it using ``%load`` (makes for a nice usage
297 when followed with :kbd:`F2`), send it to dpaste.org using ``%pastebin``, or
298 view the whole thing syntax-highlighted with a single ``%pycat``.
299
300 Traceback improvements
301 ======================
302
303
304 UPDATE THIS IN INPUT.
305
306 Previously, error tracebacks for errors happening in code cells were showing a hash, the one used for compiling the Python AST::
307
308 In [1]: def foo():
309 ...: return 3 / 0
310 ...:
311
312 In [2]: foo()
313 ---------------------------------------------------------------------------
314 ZeroDivisionError Traceback (most recent call last)
315 <ipython-input-2-c19b6d9633cf> in <module>
316 ----> 1 foo()
317
318 <ipython-input-1-1595a74c32d5> in foo()
319 1 def foo():
320 ----> 2 return 3 / 0
321 3
322
323 ZeroDivisionError: division by zero
324
325 The error traceback is now correctly formatted, showing the cell number in which the error happened::
326
327 In [1]: def foo():
328 ...: return 3 / 0
329 ...:
330
331 In [2]: foo()
332 ---------------------------------------------------------------------------
333 ZeroDivisionError Traceback (most recent call last)
334 In [2], in <module>
335 ----> 1 foo()
336
337 In [1], in foo()
338 1 def foo():
339 ----> 2 return 3 / 0
340
341 ZeroDivisionError: division by zero
342
343 Remove Deprecated Stuff
344 =======================
345
346
347 We no longer need to add `extensions` to the PYTHONPATH because that is being
348 handled by `load_extension`.
349
350 We are also removing Cythonmagic, sympyprinting and rmagic as they are now in
351 other packages and no longer need to be inside IPython.
172 352
173 353 .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
174 354
@@ -101,7 +101,7 b' pygments.lexers ='
101 101
102 102 [velin]
103 103 ignore_patterns =
104 IPython/core/tests,
104 IPython/core/tests
105 105 IPython/testing
106 106
107 107 [tool.black]
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now