diff --git a/IPython/core/crashhandler.py b/IPython/core/crashhandler.py index 181fc15..d0d4b0d 100644 --- a/IPython/core/crashhandler.py +++ b/IPython/core/crashhandler.py @@ -32,6 +32,8 @@ from IPython.utils.py3compat import input from IPython.core.release import __version__ as version +from typing import Optional + #----------------------------------------------------------------------------- # Code #----------------------------------------------------------------------------- @@ -95,8 +97,15 @@ class CrashHandler(object): message_template = _default_message_template section_sep = '\n\n'+'*'*75+'\n\n' - def __init__(self, app, contact_name=None, contact_email=None, - bug_tracker=None, show_crash_traceback=True, call_pdb=False): + def __init__( + self, + app, + contact_name: Optional[str] = None, + contact_email: Optional[str] = None, + bug_tracker: Optional[str] = None, + show_crash_traceback: bool = True, + call_pdb: bool = False, + ): """Create a new crash handler Parameters @@ -113,10 +122,15 @@ class CrashHandler(object): show_crash_traceback : bool If false, don't print the crash traceback on stderr, only generate the on-disk report - Non-argument instance attributes + call_pdb + Whether to call pdb on crash + + Attributes + ---------- These instances contain some non-argument attributes which allow for further customization of the crash handler's behavior. Please see the source for further details. + """ self.crash_report_fname = "Crash_report_%s.txt" % app.name self.app = app diff --git a/IPython/core/getipython.py b/IPython/core/getipython.py index e6d8a4c..5e9b13c 100644 --- a/IPython/core/getipython.py +++ b/IPython/core/getipython.py @@ -16,7 +16,7 @@ def get_ipython(): """Get the global InteractiveShell instance. - + Returns None if no InteractiveShell instance is registered. """ from IPython.core.interactiveshell import InteractiveShell diff --git a/IPython/core/magic.py b/IPython/core/magic.py index 7f7f1f9..3dc3480 100644 --- a/IPython/core/magic.py +++ b/IPython/core/magic.py @@ -114,16 +114,13 @@ def record_magic(dct, magic_kind, magic_name, func): Parameters ---------- dct : dict - A dictionary with 'line' and 'cell' subdicts. - + A dictionary with 'line' and 'cell' subdicts. magic_kind : str - Kind of magic to be stored. - + Kind of magic to be stored. magic_name : str - Key to store the magic as. - + Key to store the magic as. func : function - Callable object to store. + Callable object to store. """ if magic_kind == 'line_cell': dct['line'][magic_name] = dct['cell'][magic_name] = func @@ -372,7 +369,7 @@ class MagicsManager(Configurable): def register(self, *magic_objects): """Register one or more instances of Magics. - Take one or more classes or instances of classes that subclass the main + Take one or more classes or instances of classes that subclass the main `core.Magic` class, and register them with IPython to use the magic functions they provide. The registration process will then ensure that any methods that have decorated to provide line and/or cell magics will @@ -387,7 +384,7 @@ class MagicsManager(Configurable): Parameters ---------- - magic_objects : one or more classes or instances + *magic_objects : one or more classes or instances """ # Start by validating them to ensure they have all had their magic # methods registered at the instance level @@ -410,7 +407,7 @@ class MagicsManager(Configurable): This will create an IPython magic (line, cell or both) from a standalone function. The functions should have the following - signatures: + signatures: * For line magics: `def f(line)` * For cell magics: `def f(line, cell)` @@ -422,14 +419,12 @@ class MagicsManager(Configurable): Parameters ---------- func : callable - Function to be registered as a magic. - + Function to be registered as a magic. magic_kind : str - Kind of magic, one of 'line', 'cell' or 'line_cell' - + Kind of magic, one of 'line', 'cell' or 'line_cell' magic_name : optional str - If given, the name the magic will have in the IPython namespace. By - default, the name of the function itself is used. + If given, the name the magic will have in the IPython namespace. By + default, the name of the function itself is used. """ # Create the new method in the user_magics and register it in the @@ -450,13 +445,11 @@ class MagicsManager(Configurable): Parameters ---------- alias_name : str - The name of the magic to be registered. - + The name of the magic to be registered. magic_name : str - The name of an existing magic. - + The name of an existing magic. magic_kind : str - Kind of magic, one of 'line' or 'cell' + Kind of magic, one of 'line' or 'cell' """ # `validate_type` is too permissive, as it allows 'line_cell' @@ -580,25 +573,20 @@ class Magics(Configurable): Parameters ---------- - arg_str : str - The arguments to parse. - + The arguments to parse. opt_str : str - The options specification. - + The options specification. mode : str, default 'string' - If given as 'list', the argument string is returned as a list (split - on whitespace) instead of a string. - + If given as 'list', the argument string is returned as a list (split + on whitespace) instead of a string. list_all : bool, default False - Put all option values in lists. Normally only options - appearing more than once are put in a list. - + Put all option values in lists. Normally only options + appearing more than once are put in a list. posix : bool, default True - Whether to split the input line in POSIX mode or not, as per the - conventions outlined in the :mod:`shlex` module from the standard - library. + Whether to split the input line in POSIX mode or not, as per the + conventions outlined in the :mod:`shlex` module from the standard + library. """ # inject default options at the beginning of the input line diff --git a/IPython/core/page.py b/IPython/core/page.py index 4490325..24770c5 100644 --- a/IPython/core/page.py +++ b/IPython/core/page.py @@ -46,7 +46,7 @@ def display_page(strng, start=0, screen_lines=25): def as_hook(page_func): """Wrap a pager func to strip the `self` arg - + so it can be called as a hook. """ return lambda self, *args, **kwargs: page_func(*args, **kwargs) @@ -127,7 +127,7 @@ def _detect_screen_size(screen_lines_def): def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): """Display a string, piping through a pager after a certain length. - + strng can be a mime-bundle dict, supplying multiple representations, keyed by mime-type. @@ -238,10 +238,10 @@ def pager_page(strng, start=0, screen_lines=0, pager_cmd=None): def page(data, start=0, screen_lines=0, pager_cmd=None): """Display content in a pager, piping through a pager after a certain length. - + data can be a mime-bundle dict, supplying multiple representations, keyed by mime-type, or text. - + Pager is dispatched via the `show_in_pager` IPython hook. If no hook is registered, `pager_page` will be used. """ diff --git a/IPython/core/payloadpage.py b/IPython/core/payloadpage.py index eb61344..4958108 100644 --- a/IPython/core/payloadpage.py +++ b/IPython/core/payloadpage.py @@ -17,10 +17,9 @@ def page(strng, start=0, screen_lines=0, pager_cmd=None): Parameters ---------- strng : str or mime-dict - Text to page, or a mime-type keyed dict of already formatted data. - + Text to page, or a mime-type keyed dict of already formatted data. start : int - Starting line at which to place the display. + Starting line at which to place the display. """ # Some routines may auto-compute start offsets incorrectly and pass a @@ -42,7 +41,7 @@ def page(strng, start=0, screen_lines=0, pager_cmd=None): def install_payload_page(): """DEPRECATED, use show_in_pager hook - + Install this version of page as IPython.core.page.page. """ warnings.warn("""install_payload_page is deprecated. diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index 711ee75..68e100f 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -185,8 +185,8 @@ def mpl_runner(safe_execfile): Parameters ---------- safe_execfile : function - This must be a function with the same interface as the - :meth:`safe_execfile` method of IPython. + This must be a function with the same interface as the + :meth:`safe_execfile` method of IPython. Returns ------- @@ -241,7 +241,7 @@ def select_figure_formats(shell, formats, **kwargs): """Select figure formats for the inline backend. Parameters - ========== + ---------- shell : InteractiveShell The main IPython instance. formats : str or set @@ -408,7 +408,6 @@ def configure_inline_support(shell, backend): Parameters ---------- shell : InteractiveShell instance - backend : matplotlib backend """ warnings.warn( diff --git a/IPython/core/ultratb.py b/IPython/core/ultratb.py index c7ce562..5c62ee9 100644 --- a/IPython/core/ultratb.py +++ b/IPython/core/ultratb.py @@ -556,7 +556,7 @@ class ListTB(TBTools): Parameters ---------- etype : exception type - evalue : exception value + value : exception value """ return ListTB.structured_traceback(self, etype, value)