id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
176,771
from typing import ( Any, Callable, Dict, Set, Sequence, Tuple, NamedTuple, Type, Literal, Union, TYPE_CHECKING, ) import ast import builtins import collections import operator import sys from functools import cached_property from dataclasses import dataclass, field from IPyt...
Evaluate provided code in the evaluation context. If evaluation policy given by context is set to ``forbidden`` no evaluation will be performed; if it is set to ``dangerous`` standard :func:`eval` will be used; finally, for any other, policy :func:`eval_node` will be called on parsed AST.
176,772
from typing import ( Any, Callable, Dict, Set, Sequence, Tuple, NamedTuple, Type, Literal, Union, TYPE_CHECKING, ) import ast import builtins import collections import operator import sys from functools import cached_property from dataclasses import dataclass, field from IPyt...
For use on immutable objects or with methods returning a copy
176,773
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Return an ON/OFF string for a 1/0 input. Simple utility function.
176,774
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Compress a directory history into a new one with at most 20 entries. Return a new list made from the first and last 10 elements of dhist after removal of duplicates.
176,775
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Decorator to mark magic functions which need to local scope to run.
176,776
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Class decorator for all subclasses of the main Magics class. Any class that subclasses Magics *must* also apply this decorator, to ensure that all the methods that have been decorated as line/cell magics get correctly registered in the class instance. This is necessary because when method decorators run, the class does...
176,777
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Decorator factory for methods in Magics subclasses.
176,778
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Decorator factory for standalone functions.
176,779
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Mark a magic function as not needing variable expansion By default, IPython interprets `{a}` or `$a` in the line passed to magics as variables that should be interpolated from the interactive namespace before passing the line to the magic function. This is not always desirable, e.g. when the magic executes Python code ...
176,780
import os import re import sys from getopt import getopt, GetoptError from traitlets.config.configurable import Configurable from . import oinspect from .error import UsageError from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2 from ..utils.ipstruct import Struct from ..utils.process import arg_split from ..utils.te...
Mark a magic function so its output may be silenced. The output is silenced if the Python code used as a parameter of the magic ends in a semicolon, not counting a Python comment that can follow it.
176,781
from keyword import iskeyword import re from .autocall import IPyAutocall from traitlets.config.configurable import Configurable from .inputtransformer2 import ( ESC_MAGIC, ESC_QUOTE, ESC_QUOTE2, ESC_PAREN, ) from .macro import Macro from .splitinput import LineInfo from traitlets import ( List, Int...
Is the given identifier defined in one of the namespaces which shadow the alias and magic namespaces? Note that an identifier is different than ifun, because it can not contain a '.' character.
176,782
import __future__ from ast import PyCF_ONLY_AST import codeop import functools import hashlib import linecache import operator import time from contextlib import contextmanager The provided code snippet includes necessary dependencies for implementing the `code_name` function. Write a Python function `def code_name(co...
Compute a (probably) unique name for code for caching. This now expects code to be unicode.
176,783
import __future__ from ast import PyCF_ONLY_AST import codeop import functools import hashlib import linecache import operator import time from contextlib import contextmanager The provided code snippet includes necessary dependencies for implementing the `check_linecache_ipython` function. Write a Python function `de...
Deprecated since IPython 8.6. Call linecache.checkcache() directly. It was already not necessary to call this function directly. If no CachingCompiler had been created, this function would fail badly. If an instance had been created, this function would've been monkeypatched into place. As of IPython 8.6, the monkeypat...
176,784
import sys import traceback from pprint import pformat from pathlib import Path from IPython.core import ultratb from IPython.core.release import author_email from IPython.utils.sysinfo import sys_info from IPython.utils.py3compat import input from IPython.core.release import __version__ as version from typing import O...
a light excepthook, adding a small message to the usual traceback
176,785
import ast import bdb import builtins as builtin_mod import cProfile as profile import gc import itertools import math import os import pstats import re import shlex import sys import time import timeit from ast import Module from io import StringIO from logging import error from pathlib import Path from pdb import Res...
Returns (file, line) for file:line and (current_file, line) for line
176,786
import ast import bdb import builtins as builtin_mod import cProfile as profile import gc import itertools import math import os import pstats import re import shlex import sys import time import timeit from ast import Module from io import StringIO from logging import error from pathlib import Path from pdb import Res...
Formats the timespan in a human readable form
176,787
import inspect import io import os import re import sys import ast from itertools import chain from urllib.request import Request, urlopen from urllib.parse import urlencode from pathlib import Path from IPython.core.error import TryNext, StdinNotImplementedError, UsageError from IPython.core.macro import Macro from IP...
Turn a string of range for %%load into 2-tuples of (start, stop) ready to use as a slice of the content split by lines. Examples -------- list(extract_input_ranges("5-10 2")) [(4, 10), (1, 2)]
176,788
import inspect import io import os import re import sys import ast from itertools import chain from urllib.request import Request, urlopen from urllib.parse import urlencode from pathlib import Path from IPython.core.error import TryNext, StdinNotImplementedError, UsageError from IPython.core.macro import Macro from IP...
Return a tuple (blocks, not_found) where ``blocks`` is a list of code fragments for each symbol parsed from code, and ``not_found`` are symbols not found in the code. For example:: In [1]: code = '''a = 10 ...: def b(): return 42 ...: class A: pass''' In [2]: extract_symbols(code, 'A,b,z') Out[2]: (['class A: pass\\n',...
176,789
import inspect import io import os import re import sys import ast from itertools import chain from urllib.request import Request, urlopen from urllib.parse import urlencode from pathlib import Path from IPython.core.error import TryNext, StdinNotImplementedError, UsageError from IPython.core.macro import Macro from IP...
For %load, strip indent from lines until finding an unindented line. https://github.com/ipython/ipython/issues/9775
176,790
import asyncio import atexit import errno import os import signal import sys import time from subprocess import CalledProcessError from threading import Thread from traitlets import Any, Dict, List, default from IPython.core import magic_arguments from IPython.core.async_helpers import _AsyncIOProxy from IPython.core.m...
single decorator for adding script args
176,791
import re import shlex import sys from pathlib import Path from IPython.core.magic import Magics, magics_class, line_magic class Path(PurePath): def __new__(cls: Type[_P], *args: Union[str, _PathLike], **kwargs: Any) -> _P: ... def __enter__(self: _P) -> _P: ... def __exit__( self, exc_type: Option...
Return True if the current Python executable is in a conda env
176,792
import re import shlex import sys from pathlib import Path from IPython.core.magic import Magics, magics_class, line_magic class Path(PurePath): def __new__(cls: Type[_P], *args: Union[str, _PathLike], **kwargs: Any) -> _P: ... def __enter__(self: _P) -> _P: ... def __exit__( self, exc_type: Option...
Find the path to the conda executable
176,793
import os from traitlets.config.application import Application from IPython.core.application import ( BaseIPythonApplication, base_flags ) from IPython.core.profiledir import ProfileDir from IPython.utils.importstring import import_item from IPython.paths import get_ipython_dir, get_ipython_package_dir from traitle...
list profiles in a given root directory
176,794
import os from traitlets.config.application import Application from IPython.core.application import ( BaseIPythonApplication, base_flags ) from IPython.core.profiledir import ProfileDir from IPython.utils.importstring import import_item from IPython.paths import get_ipython_dir, get_ipython_package_dir from traitle...
list profiles that are bundled with IPython.
176,795
import glob import inspect import os import re import sys from importlib import import_module from importlib.machinery import all_suffixes from time import time from zipimport import zipimporter from .completer import expand_user, compress_user from .error import TryNext from ..utils._process_common import arg_split fr...
r""" Easily create a trivial completer for a command. Takes either a list of completions, or all completions in string (that will be split on whitespace). Example:: [d:\ipython]|1> import ipy_completers [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz']) [d:\ipython]|3> foo b<TAB> bar baz [d:\ipython]|...
176,796
import glob import inspect import os import re import sys from importlib import import_module from importlib.machinery import all_suffixes from time import time from zipimport import zipimporter from .completer import expand_user, compress_user from .error import TryNext from ..utils._process_common import arg_split fr...
Give completions after user has typed 'import ...' or 'from ...
176,797
import glob import inspect import os import re import sys from importlib import import_module from importlib.machinery import all_suffixes from time import time from zipimport import zipimporter from .completer import expand_user, compress_user from .error import TryNext from ..utils._process_common import arg_split fr...
Complete files that end in .py or .ipy or .ipynb for the %run command.
176,798
import glob import inspect import os import re import sys from importlib import import_module from importlib.machinery import all_suffixes from time import time from zipimport import zipimporter from .completer import expand_user, compress_user from .error import TryNext from ..utils._process_common import arg_split fr...
Completer function for cd, which only returns directories.
176,799
import glob import inspect import os import re import sys from importlib import import_module from importlib.machinery import all_suffixes from time import time from zipimport import zipimporter from .completer import expand_user, compress_user from .error import TryNext from ..utils._process_common import arg_split fr...
A completer for %reset magic
176,800
from binascii import b2a_hex import os import sys import warnings def display( *objs, include=None, exclude=None, metadata=None, transient=None, display_id=None, raw=False, clear=False, **kwargs ): """Display a Python object in all frontends. By default all representations wi...
Update an existing display by id Parameters ---------- obj The object with which to update the display display_id : keyword-only The id of the display to update See Also -------- :func:`display`
176,801
import warnings from IPython.core.getipython import get_ipython def page(strng, start=0, screen_lines=0, pager_cmd=None): """Print a string, piping through a pager. This version ignores the screen_lines and pager_cmd arguments and uses IPython's payload system instead. Parameters ---------- strn...
DEPRECATED, use show_in_pager hook Install this version of page as IPython.core.page.page.
176,802
import re import sys from IPython.utils import py3compat from IPython.utils.encoding import get_stream_enc from IPython.core.oinspect import OInfo line_split = re.compile(r""" ^(\s*) # any leading space ([,;/%]|!!?|\?\??)? # escape character or characters \s*(%{0,2}...
Split user input into initial whitespace, escape character, function part and the rest.
176,803
import os import io import re import sys import tempfile import subprocess from io import UnsupportedOperation from pathlib import Path from IPython import get_ipython from IPython.display import display from IPython.core.error import TryNext from IPython.utils.data import chop from IPython.utils.process import system ...
Just display, no paging. screen_lines is ignored.
176,804
import os import io import re import sys import tempfile import subprocess from io import UnsupportedOperation from pathlib import Path from IPython import get_ipython from IPython.display import display from IPython.core.error import TryNext from IPython.utils.data import chop from IPython.utils.process import system ...
Wrap a pager func to strip the `self` arg so it can be called as a hook.
176,805
import os import io import re import sys import tempfile import subprocess from io import UnsupportedOperation from pathlib import Path from IPython import get_ipython from IPython.display import display from IPython.core.error import TryNext from IPython.utils.data import chop from IPython.utils.process import system ...
Page a file, using an optional pager command and starting line.
176,806
import atexit import datetime from pathlib import Path import re import sqlite3 import threading from traitlets.config.configurable import LoggingConfigurable from decorator import decorator from IPython.utils.decorators import undoc from IPython.paths import locate_profile from traitlets import ( Any, Bool, ...
Decorator: return an empty list in the absence of sqlite.
176,807
import atexit import datetime from pathlib import Path import re import sqlite3 import threading from traitlets.config.configurable import LoggingConfigurable from decorator import decorator from IPython.utils.decorators import undoc from IPython.paths import locate_profile from traitlets import ( Any, Bool, ...
A decorator which wraps HistoryAccessor method calls to catch errors from a corrupt SQLite database, move the old database out of the way, and create a new one. We avoid clobbering larger databases because this may be triggered due to filesystem issues, not just a corrupt file.
176,808
import atexit import datetime from pathlib import Path import re import sqlite3 import threading from traitlets.config.configurable import LoggingConfigurable from decorator import decorator from IPython.utils.decorators import undoc from IPython.paths import locate_profile from traitlets import ( Any, Bool, ...
Turn a string of history ranges into 3-tuples of (session, start, stop). Empty string results in a `[(0, 1, None)]`, i.e. "everything from current session". Examples -------- >>> list(extract_hist_ranges("~8/5-~7/4 2")) [(-8, 5, None), (-7, 1, 5), (0, 2, 3)]
176,809
import atexit import datetime from pathlib import Path import re import sqlite3 import threading from traitlets.config.configurable import LoggingConfigurable from decorator import decorator from IPython.utils.decorators import undoc from IPython.paths import locate_profile from traitlets import ( Any, Bool, ...
Helper function to format line numbers properly.
176,810
import inspect import linecache import pydoc import sys import time import traceback from types import TracebackType from typing import Tuple, List, Any, Optional import stack_data from stack_data import FrameInfo as SDFrameInfo from pygments.formatters.terminal256 import Terminal256Formatter from pygments.styles impor...
Format tracebacks lines with pointing arrow, leading numbers... Parameters ---------- lines : list[Line] Colors ColorScheme used. lvals : str Values of local variables, already colored, to inject just after the error line.
176,811
import inspect import linecache import pydoc import sys import time import traceback from types import TracebackType from typing import Tuple, List, Any, Optional import stack_data from stack_data import FrameInfo as SDFrameInfo from pygments.formatters.terminal256 import Terminal256Formatter from pygments.styles impor...
Format tracebacks lines with pointing arrow, leading numbers... Parameters ========== lnum: int number of the target line of code. index: int which line in the list should be highlighted. lines: list[string] Colors: ColorScheme used. lvals: bytes Values of local variables, already colored, to inject just after the erro...
176,812
import inspect import linecache import pydoc import sys import time import traceback from types import TracebackType from typing import Tuple, List, Any, Optional import stack_data from stack_data import FrameInfo as SDFrameInfo from pygments.formatters.terminal256 import Terminal256Formatter from pygments.styles impor...
Format filename lines with custom formatting from caching compiler or `File *.py` by default Parameters ---------- file : str ColorFilename ColorScheme's filename coloring to be used. ColorNormal ColorScheme's normal coloring to be used.
176,813
import inspect import linecache import pydoc import sys import time import traceback from types import TracebackType from typing import Tuple, List, Any, Optional import stack_data from stack_data import FrameInfo as SDFrameInfo from pygments.formatters.terminal256 import Terminal256Formatter from pygments.styles impor...
null
176,814
import inspect import linecache import pydoc import sys import time import traceback from types import TracebackType from typing import Tuple, List, Any, Optional import stack_data from stack_data import FrameInfo as SDFrameInfo from pygments.formatters.terminal256 import Terminal256Formatter from pygments.styles impor...
null
176,815
import asyncio import os import sys from warnings import warn from typing import Union as UnionType from IPython.core.async_helpers import get_asyncio_loop from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC from IPython.utils.py3compat import input from IPython.utils.terminal import toggle_...
null
176,816
import asyncio import os import sys from warnings import warn from typing import Union as UnionType from IPython.core.async_helpers import get_asyncio_loop from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC from IPython.utils.py3compat import input from IPython.utils.terminal import toggle_...
We do not need to protect against error, this is taken care at a higher level where any reformat error is ignored. Indeed we may call reformatting on incomplete code.
176,817
import asyncio import os import sys from warnings import warn from typing import Union as UnionType from IPython.core.async_helpers import get_asyncio_loop from IPython.core.interactiveshell import InteractiveShell, InteractiveShellABC from IPython.utils.py3compat import input from IPython.utils.terminal import toggle_...
null
176,818
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `parenthesis` function. Write a Python function `def parenthesis(event: KeyPressEvent)` to solve the following problem: Auto-close parenthesis Here is the function: def parent...
Auto-close parenthesis
176,819
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `brackets` function. Write a Python function `def brackets(event: KeyPressEvent)` to solve the following problem: Auto-close brackets Here is the function: def brackets(event:...
Auto-close brackets
176,820
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `braces` function. Write a Python function `def braces(event: KeyPressEvent)` to solve the following problem: Auto-close braces Here is the function: def braces(event: KeyPres...
Auto-close braces
176,821
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `double_quote` function. Write a Python function `def double_quote(event: KeyPressEvent)` to solve the following problem: Auto-close double quotes Here is the function: def do...
Auto-close double quotes
176,822
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `single_quote` function. Write a Python function `def single_quote(event: KeyPressEvent)` to solve the following problem: Auto-close single quotes Here is the function: def si...
Auto-close single quotes
176,823
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `docstring_double_quotes` function. Write a Python function `def docstring_double_quotes(event: KeyPressEvent)` to solve the following problem: Auto-close docstring (double quot...
Auto-close docstring (double quotes)
176,824
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `docstring_single_quotes` function. Write a Python function `def docstring_single_quotes(event: KeyPressEvent)` to solve the following problem: Auto-close docstring (single quot...
Auto-close docstring (single quotes)
176,825
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `raw_string_parenthesis` function. Write a Python function `def raw_string_parenthesis(event: KeyPressEvent)` to solve the following problem: Auto-close parenthesis in raw strin...
Auto-close parenthesis in raw strings
176,826
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `raw_string_bracket` function. Write a Python function `def raw_string_bracket(event: KeyPressEvent)` to solve the following problem: Auto-close bracker in raw strings Here is ...
Auto-close bracker in raw strings
176,827
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `raw_string_braces` function. Write a Python function `def raw_string_braces(event: KeyPressEvent)` to solve the following problem: Auto-close braces in raw strings Here is the...
Auto-close braces in raw strings
176,828
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `skip_over` function. Write a Python function `def skip_over(event: KeyPressEvent)` to solve the following problem: Skip over automatically added parenthesis/quote. (rather than...
Skip over automatically added parenthesis/quote. (rather than adding another parenthesis/quote)
176,829
import re from prompt_toolkit.key_binding import KeyPressEvent The provided code snippet includes necessary dependencies for implementing the `delete_pair` function. Write a Python function `def delete_pair(event: KeyPressEvent)` to solve the following problem: Delete auto-closed parenthesis Here is the function: de...
Delete auto-closed parenthesis
176,830
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,831
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
Wrapper around has_focus adding a nice `__name__` to tester function
176,832
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,833
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,834
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,835
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,836
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,837
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,838
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,839
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,840
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,841
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,842
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,843
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,844
import ast import re import signal import sys from typing import Callable, Dict, Union from prompt_toolkit.application.current import get_app from prompt_toolkit.enums import DEFAULT_BUFFER, SEARCH_BUFFER from prompt_toolkit.filters import Condition, emacs_insert_mode, has_completions from prompt_toolkit.filters import...
null
176,845
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Accept autosuggestion
176,846
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Discard autosuggestion
176,847
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Fill partial autosuggestion by word
176,848
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Fill partial autosuggestion by character
176,849
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Accept autosuggestion and move cursor left in place
176,850
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Resume autosuggestions after deleting last character
176,851
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Resume autosuggestions
176,852
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Go up and update hint
176,853
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Go down and update hint
176,854
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Fill partial autosuggestion by token
176,855
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Get next autosuggestion from history.
176,856
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
Get previous autosuggestion from history.
176,857
import re import tokenize from io import StringIO from typing import Callable, List, Optional, Union, Generator, Tuple import warnings from prompt_toolkit.buffer import Buffer from prompt_toolkit.key_binding import KeyPressEvent from prompt_toolkit.key_binding.bindings import named_commands as nc from prompt_toolkit.au...
null
176,858
import asyncio import os import sys from IPython.core.debugger import Pdb from IPython.core.completer import IPCompleter from .ptutils import IPythonPTCompleter from .shortcuts import create_ipython_shortcuts from . import embed from pathlib import Path from pygments.token import Token from prompt_toolkit.shortcuts.pro...
Start debugging from `frame`. If frame is not specified, debugging starts from caller's frame.
176,859
import unicodedata from wcwidth import wcwidth from IPython.core.completer import ( provisionalcompleter, cursor_to_position, _deduplicate_completions) from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.lexers import Lexer from prompt_toolkit.lexers import PygmentsLexer from prompt_...
null
176,860
import unicodedata from wcwidth import wcwidth from IPython.core.completer import ( provisionalcompleter, cursor_to_position, _deduplicate_completions) from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.lexers import Lexer from prompt_toolkit.lexers import PygmentsLexer from prompt_...
null
176,861
import sys import os from IPython.external.qt_for_kernel import QtCore, QtGui, enum_helper from IPython import get_ipython _appref = None _already_warned = False def _exec(obj): # exec on PyQt6, exec_ elsewhere. obj.exec() if hasattr(obj, "exec") else obj.exec_() def _reclaim_excepthook(): shell = get_ipyth...
null
176,862
from gi.repository import GLib class _InputHook: def __init__(self, context): def quit(self, *args, **kwargs): def run(self): def inputhook(context): hook = _InputHook(context) hook.run()
null
176,863
import sys import signal import time from timeit import default_timer as clock import wx The provided code snippet includes necessary dependencies for implementing the `ignore_keyboardinterrupts` function. Write a Python function `def ignore_keyboardinterrupts(func)` to solve the following problem: Decorator which cau...
Decorator which causes KeyboardInterrupt exceptions to be ignored during execution of the decorated function. This is used by the inputhook functions to handle the event where the user presses CTRL+C while IPython is idle, and the inputhook loop is running. In this case, we want to ignore interrupts.
176,864
import sys import signal import time from timeit import default_timer as clock import wx import wx The provided code snippet includes necessary dependencies for implementing the `inputhook_wx1` function. Write a Python function `def inputhook_wx1(context)` to solve the following problem: Run the wx event loop by proc...
Run the wx event loop by processing pending events only. This approach seems to work, but its performance is not great as it relies on having PyOS_InputHook called regularly.
176,865
import sys import signal import time from timeit import default_timer as clock import wx class EventLoopRunner(object): def Run(self, time, input_is_ready): self.input_is_ready = input_is_ready self.evtloop = wx.EventLoop() self.timer = EventLoopTimer(self.check_stdin) self.timer.Sta...
Run the wx event loop, polling for stdin. This version runs the wx eventloop for an undetermined amount of time, during which it periodically checks to see if anything is ready on stdin. If anything is ready on stdin, the event loop exits. The argument to elr.Run controls how often the event loop looks at stdin. This d...
176,866
import sys import signal import time from timeit import default_timer as clock import wx import wx The provided code snippet includes necessary dependencies for implementing the `inputhook_wx3` function. Write a Python function `def inputhook_wx3(context)` to solve the following problem: Run the wx event loop by proc...
Run the wx event loop by processing pending events only. This is like inputhook_wx1, but it keeps processing pending events until stdin is ready. After processing all pending events, a call to time.sleep is inserted. This is needed, otherwise, CPU usage is at 100%. This sleep time should be tuned though for best perfor...
176,867
import sys import signal import time from timeit import default_timer as clock import wx import wx The provided code snippet includes necessary dependencies for implementing the `inputhook_wxphoenix` function. Write a Python function `def inputhook_wxphoenix(context)` to solve the following problem: Run the wx event ...
Run the wx event loop until the user provides more input. This input hook is suitable for use with wxPython >= 4 (a.k.a. Phoenix). It uses the same approach to that used in ipykernel.eventloops.loop_wx. The wx.MainLoop is executed, and a wx.Timer is used to periodically poll the context for input. As soon as input is r...
176,868
from prompt_toolkit import __version__ as ptk_version from IPython.core.async_helpers import get_asyncio_loop PTK3 = ptk_version.startswith("3.") def get_asyncio_loop(): """asyncio has deprecated get_event_loop Replicate it here, with our desired semantics: - always returns a valid, not-closed loop -...
Inputhook for asyncio event loop integration.
176,869
import time import _tkinter import tkinter The provided code snippet includes necessary dependencies for implementing the `inputhook` function. Write a Python function `def inputhook(inputhook_context)` to solve the following problem: Inputhook for Tk. Run the Tk eventloop until prompt-toolkit needs to process the nex...
Inputhook for Tk. Run the Tk eventloop until prompt-toolkit needs to process the next input.
176,870
import sys import time from timeit import default_timer as clock import pyglet if sys.platform.startswith('linux'): def flip(window): try: window.flip() except AttributeError: pass else: def flip(window): window.flip() import pyglet The provided code snippet inc...
Run the pyglet event loop by processing pending events only. This keeps processing pending events until stdin is ready. After processing all pending events, a call to time.sleep is inserted. This is needed, otherwise, CPU usage is at 100%. This sleep time should be tuned though for best performance.