aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-12-18 11:04:10 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-12-18 11:18:13 +0300
commitdcbf444872b81248ce958f05d47abad6e8a237a7 (patch)
treea93610b3dd80f19c5116e4e5885ea2783f6166d3 /contrib/python/ipython/py3
parente2c38d5aa55a58da33c1dc54792c131023bb7472 (diff)
downloadydb-dcbf444872b81248ce958f05d47abad6e8a237a7.tar.gz
Intermediate changes
commit_hash:1f2ebe313aea1039145a9d68dcd511d5f22f383a
Diffstat (limited to 'contrib/python/ipython/py3')
-rw-r--r--contrib/python/ipython/py3/.dist-info/METADATA96
-rw-r--r--contrib/python/ipython/py3/IPython/core/completer.py6
-rw-r--r--contrib/python/ipython/py3/IPython/core/crashhandler.py54
-rw-r--r--contrib/python/ipython/py3/IPython/core/display.py11
-rw-r--r--contrib/python/ipython/py3/IPython/core/formatters.py125
-rw-r--r--contrib/python/ipython/py3/IPython/core/guarded_eval.py15
-rw-r--r--contrib/python/ipython/py3/IPython/core/inputsplitter.py1
-rw-r--r--contrib/python/ipython/py3/IPython/core/inputtransformer2.py5
-rw-r--r--contrib/python/ipython/py3/IPython/core/magics/basic.py4
-rw-r--r--contrib/python/ipython/py3/IPython/core/magics/logging.py4
-rw-r--r--contrib/python/ipython/py3/IPython/core/prompts.py4
-rw-r--r--contrib/python/ipython/py3/IPython/core/release.py2
-rw-r--r--contrib/python/ipython/py3/IPython/external/qt_loaders.py1
-rw-r--r--contrib/python/ipython/py3/IPython/lib/__init__.py4
-rw-r--r--contrib/python/ipython/py3/IPython/lib/clipboard.py1
-rw-r--r--contrib/python/ipython/py3/IPython/lib/latextools.py8
-rw-r--r--contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py2
-rw-r--r--contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py30
-rw-r--r--contrib/python/ipython/py3/IPython/terminal/interactiveshell.py33
-rw-r--r--contrib/python/ipython/py3/IPython/terminal/shortcuts/__init__.py8
-rw-r--r--contrib/python/ipython/py3/IPython/terminal/shortcuts/auto_match.py1
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_process_cli.py4
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_process_win32.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/dir2.py4
-rw-r--r--contrib/python/ipython/py3/IPython/utils/sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/patches/02-fix-ya.make.patch4
-rw-r--r--contrib/python/ipython/py3/ya.make2
28 files changed, 268 insertions, 167 deletions
diff --git a/contrib/python/ipython/py3/.dist-info/METADATA b/contrib/python/ipython/py3/.dist-info/METADATA
index c1f48dd50c..08d01e914e 100644
--- a/contrib/python/ipython/py3/.dist-info/METADATA
+++ b/contrib/python/ipython/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: ipython
-Version: 8.29.0
+Version: 8.30.0
Summary: IPython: Productive Interactive Computing
Author: The IPython Development Team
Author-email: ipython-dev@python.org
@@ -26,65 +26,65 @@ Classifier: Topic :: System :: Shells
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
+Requires-Dist: colorama; sys_platform == "win32"
Requires-Dist: decorator
-Requires-Dist: jedi >=0.13
+Requires-Dist: exceptiongroup; python_version < "3.11"
+Requires-Dist: jedi>=0.13
Requires-Dist: matplotlib-inline
-Requires-Dist: prompt-toolkit <3.1.0,>=3.0.41
-Requires-Dist: pygments >=2.4.0
-Requires-Dist: stack-data
-Requires-Dist: traitlets >=5.13.0
-Requires-Dist: exceptiongroup ; python_version < "3.11"
-Requires-Dist: typing-extensions >=4.6 ; python_version < "3.12"
-Requires-Dist: pexpect >4.3 ; sys_platform != "win32" and sys_platform != "emscripten"
-Requires-Dist: colorama ; sys_platform == "win32"
-Provides-Extra: all
-Requires-Dist: ipython[black,doc,kernel,matplotlib,nbconvert,nbformat,notebook,parallel,qtconsole] ; extra == 'all'
-Requires-Dist: ipython[test,test_extra] ; extra == 'all'
+Requires-Dist: pexpect>4.3; sys_platform != "win32" and sys_platform != "emscripten"
+Requires-Dist: prompt_toolkit<3.1.0,>=3.0.41
+Requires-Dist: pygments>=2.4.0
+Requires-Dist: stack_data
+Requires-Dist: traitlets>=5.13.0
+Requires-Dist: typing_extensions>=4.6; python_version < "3.12"
Provides-Extra: black
-Requires-Dist: black ; extra == 'black'
+Requires-Dist: black; extra == "black"
Provides-Extra: doc
-Requires-Dist: docrepr ; extra == 'doc'
-Requires-Dist: exceptiongroup ; extra == 'doc'
-Requires-Dist: intersphinx-registry ; extra == 'doc'
-Requires-Dist: ipykernel ; extra == 'doc'
-Requires-Dist: ipython[test] ; extra == 'doc'
-Requires-Dist: matplotlib ; extra == 'doc'
-Requires-Dist: setuptools >=18.5 ; extra == 'doc'
-Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
-Requires-Dist: sphinx >=1.3 ; extra == 'doc'
-Requires-Dist: sphinxcontrib-jquery ; extra == 'doc'
-Requires-Dist: typing-extensions ; extra == 'doc'
-Requires-Dist: tomli ; (python_version < "3.11") and extra == 'doc'
+Requires-Dist: docrepr; extra == "doc"
+Requires-Dist: exceptiongroup; extra == "doc"
+Requires-Dist: intersphinx_registry; extra == "doc"
+Requires-Dist: ipykernel; extra == "doc"
+Requires-Dist: ipython[test]; extra == "doc"
+Requires-Dist: matplotlib; extra == "doc"
+Requires-Dist: setuptools>=18.5; extra == "doc"
+Requires-Dist: sphinx-rtd-theme; extra == "doc"
+Requires-Dist: sphinx>=1.3; extra == "doc"
+Requires-Dist: sphinxcontrib-jquery; extra == "doc"
+Requires-Dist: tomli; python_version < "3.11" and extra == "doc"
+Requires-Dist: typing_extensions; extra == "doc"
Provides-Extra: kernel
-Requires-Dist: ipykernel ; extra == 'kernel'
-Provides-Extra: matplotlib
-Requires-Dist: matplotlib ; extra == 'matplotlib'
+Requires-Dist: ipykernel; extra == "kernel"
Provides-Extra: nbconvert
-Requires-Dist: nbconvert ; extra == 'nbconvert'
+Requires-Dist: nbconvert; extra == "nbconvert"
Provides-Extra: nbformat
-Requires-Dist: nbformat ; extra == 'nbformat'
+Requires-Dist: nbformat; extra == "nbformat"
Provides-Extra: notebook
-Requires-Dist: ipywidgets ; extra == 'notebook'
-Requires-Dist: notebook ; extra == 'notebook'
+Requires-Dist: ipywidgets; extra == "notebook"
+Requires-Dist: notebook; extra == "notebook"
Provides-Extra: parallel
-Requires-Dist: ipyparallel ; extra == 'parallel'
+Requires-Dist: ipyparallel; extra == "parallel"
Provides-Extra: qtconsole
-Requires-Dist: qtconsole ; extra == 'qtconsole'
+Requires-Dist: qtconsole; extra == "qtconsole"
Provides-Extra: terminal
Provides-Extra: test
-Requires-Dist: pytest ; extra == 'test'
-Requires-Dist: pytest-asyncio <0.22 ; extra == 'test'
-Requires-Dist: testpath ; extra == 'test'
-Requires-Dist: pickleshare ; extra == 'test'
-Requires-Dist: packaging ; extra == 'test'
-Provides-Extra: test_extra
-Requires-Dist: ipython[test] ; extra == 'test_extra'
-Requires-Dist: curio ; extra == 'test_extra'
-Requires-Dist: matplotlib !=3.2.0 ; extra == 'test_extra'
-Requires-Dist: nbformat ; extra == 'test_extra'
-Requires-Dist: numpy >=1.23 ; extra == 'test_extra'
-Requires-Dist: pandas ; extra == 'test_extra'
-Requires-Dist: trio ; extra == 'test_extra'
+Requires-Dist: pytest; extra == "test"
+Requires-Dist: pytest-asyncio<0.22; extra == "test"
+Requires-Dist: testpath; extra == "test"
+Requires-Dist: pickleshare; extra == "test"
+Requires-Dist: packaging; extra == "test"
+Provides-Extra: test-extra
+Requires-Dist: ipython[test]; extra == "test-extra"
+Requires-Dist: curio; extra == "test-extra"
+Requires-Dist: matplotlib!=3.2.0; extra == "test-extra"
+Requires-Dist: nbformat; extra == "test-extra"
+Requires-Dist: numpy>=1.23; extra == "test-extra"
+Requires-Dist: pandas; extra == "test-extra"
+Requires-Dist: trio; extra == "test-extra"
+Provides-Extra: matplotlib
+Requires-Dist: matplotlib; extra == "matplotlib"
+Provides-Extra: all
+Requires-Dist: ipython[black,doc,kernel,matplotlib,nbconvert,nbformat,notebook,parallel,qtconsole]; extra == "all"
+Requires-Dist: ipython[test,test_extra]; extra == "all"
IPython provides a rich toolkit to help you make the most out of using Python
interactively. Its main components are:
diff --git a/contrib/python/ipython/py3/IPython/core/completer.py b/contrib/python/ipython/py3/IPython/core/completer.py
index 8f843dd584..8260975765 100644
--- a/contrib/python/ipython/py3/IPython/core/completer.py
+++ b/contrib/python/ipython/py3/IPython/core/completer.py
@@ -1362,9 +1362,9 @@ def match_dict_keys(
# All checks passed!
return True
- filtered_key_is_final: Dict[
- Union[str, bytes, int, float], _DictKeyState
- ] = defaultdict(lambda: _DictKeyState.BASELINE)
+ filtered_key_is_final: Dict[Union[str, bytes, int, float], _DictKeyState] = (
+ defaultdict(lambda: _DictKeyState.BASELINE)
+ )
for k in keys:
# If at least one of the matches is not final, mark as undetermined.
diff --git a/contrib/python/ipython/py3/IPython/core/crashhandler.py b/contrib/python/ipython/py3/IPython/core/crashhandler.py
index f60a75bbc5..9c75c5d87c 100644
--- a/contrib/python/ipython/py3/IPython/core/crashhandler.py
+++ b/contrib/python/ipython/py3/IPython/core/crashhandler.py
@@ -24,14 +24,17 @@ import traceback
from pprint import pformat
from pathlib import Path
+import builtins as builtin_mod
+
from IPython.core import ultratb
+from IPython.core.application import Application
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 Optional
+from typing import Optional, Dict
+import types
#-----------------------------------------------------------------------------
# Code
@@ -84,7 +87,7 @@ Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
"""
-class CrashHandler(object):
+class CrashHandler:
"""Customizable crash handlers for IPython applications.
Instances of this class provide a :meth:`__call__` method which can be
@@ -95,10 +98,11 @@ class CrashHandler(object):
message_template = _default_message_template
section_sep = '\n\n'+'*'*75+'\n\n'
+ info: Dict[str, Optional[str]]
def __init__(
self,
- app,
+ app: Application,
contact_name: Optional[str] = None,
contact_email: Optional[str] = None,
bug_tracker: Optional[str] = None,
@@ -142,10 +146,14 @@ class CrashHandler(object):
bug_tracker = bug_tracker,
crash_report_fname = self.crash_report_fname)
-
- def __call__(self, etype, evalue, etb):
+ def __call__(
+ self,
+ etype: type[BaseException],
+ evalue: BaseException,
+ etb: types.TracebackType,
+ ) -> None:
"""Handle an exception, call for compatible with sys.excepthook"""
-
+
# do not allow the crash handler to be called twice without reinstalling it
# this prevents unlikely errors in the crash handling from entering an
# infinite loop.
@@ -155,21 +163,23 @@ class CrashHandler(object):
color_scheme = 'NoColor'
# Use this ONLY for developer debugging (keep commented out for release)
- #color_scheme = 'Linux' # dbg
- try:
- rptdir = self.app.ipython_dir
- except:
+ # color_scheme = 'Linux' # dbg
+ ipython_dir = getattr(self.app, "ipython_dir", None)
+ if ipython_dir is not None:
+ assert isinstance(ipython_dir, str)
+ rptdir = Path(ipython_dir)
+ else:
rptdir = Path.cwd()
- if rptdir is None or not Path.is_dir(rptdir):
+ if not rptdir.is_dir():
rptdir = Path.cwd()
report_name = rptdir / self.crash_report_fname
# write the report filename into the instance dict so it can get
# properly expanded out in the user message template
- self.crash_report_fname = report_name
- self.info['crash_report_fname'] = report_name
+ self.crash_report_fname = str(report_name)
+ self.info["crash_report_fname"] = str(report_name)
TBhandler = ultratb.VerboseTB(
color_scheme=color_scheme,
- long_header=1,
+ long_header=True,
call_pdb=self.call_pdb,
)
if self.call_pdb:
@@ -195,11 +205,11 @@ class CrashHandler(object):
print(self.message_template.format(**self.info), file=sys.stderr)
# Construct report on disk
- report.write(self.make_report(traceback))
+ report.write(self.make_report(str(traceback)))
- input("Hit <Enter> to quit (your terminal may close):")
+ builtin_mod.input("Hit <Enter> to quit (your terminal may close):")
- def make_report(self,traceback):
+ def make_report(self, traceback: str) -> str:
"""Return a string containing a crash report."""
sec_sep = self.section_sep
@@ -211,8 +221,8 @@ class CrashHandler(object):
try:
config = pformat(self.app.config)
rpt_add(sec_sep)
- rpt_add('Application name: %s\n\n' % self.app_name)
- rpt_add('Current user configuration structure:\n\n')
+ rpt_add("Application name: %s\n\n" % self.app.name)
+ rpt_add("Current user configuration structure:\n\n")
rpt_add(config)
except:
pass
@@ -221,7 +231,9 @@ class CrashHandler(object):
return ''.join(report)
-def crash_handler_lite(etype, evalue, tb):
+def crash_handler_lite(
+ etype: type[BaseException], evalue: BaseException, tb: types.TracebackType
+) -> None:
"""a light excepthook, adding a small message to the usual traceback"""
traceback.print_exception(etype, evalue, tb)
diff --git a/contrib/python/ipython/py3/IPython/core/display.py b/contrib/python/ipython/py3/IPython/core/display.py
index c3c44016f4..a9434473a8 100644
--- a/contrib/python/ipython/py3/IPython/core/display.py
+++ b/contrib/python/ipython/py3/IPython/core/display.py
@@ -16,7 +16,8 @@ from copy import deepcopy
from os.path import splitext
from pathlib import Path, PurePath
-from IPython.utils.py3compat import cast_unicode
+from typing import Optional
+
from IPython.testing.skipdoctest import skip_doctest
from . import display_functions
@@ -518,7 +519,7 @@ class SVG(DisplayObject):
_read_flags = 'rb'
# wrap data in a property, which extracts the <svg> tag, discarding
# document headers
- _data = None
+ _data: Optional[str] = None
@property
def data(self):
@@ -540,8 +541,10 @@ class SVG(DisplayObject):
# fallback on the input, trust the user
# but this is probably an error.
pass
- svg = cast_unicode(svg)
- self._data = svg
+ if isinstance(svg, bytes):
+ self._data = svg.decode(errors="replace")
+ else:
+ self._data = svg
def _repr_svg_(self):
return self._data_and_metadata()
diff --git a/contrib/python/ipython/py3/IPython/core/formatters.py b/contrib/python/ipython/py3/IPython/core/formatters.py
index 9e59e23de1..dcd82bdc5c 100644
--- a/contrib/python/ipython/py3/IPython/core/formatters.py
+++ b/contrib/python/ipython/py3/IPython/core/formatters.py
@@ -1,6 +1,61 @@
# -*- coding: utf-8 -*-
"""Display formatters.
+This module defines the base instances in order to implement custom
+formatters/mimetypes
+got objects:
+
+As we want to see internal IPython working we are going to use the following
+function to diaply objects instead of the normal print or display method:
+
+ >>> ip = get_ipython()
+ >>> ip.display_formatter.format(...)
+ ({'text/plain': 'Ellipsis'}, {})
+
+This return a tuple with the mimebumdle for the current object, and the
+associated metadata.
+
+
+We can now define our own formatter and register it:
+
+
+ >>> from IPython.core.formatters import BaseFormatter, FormatterABC
+
+
+ >>> class LLMFormatter(BaseFormatter):
+ ...
+ ... format_type = 'x-vendor/llm'
+ ... print_method = '_repr_llm_'
+ ... _return_type = (dict, str)
+
+ >>> llm_formatter = LLMFormatter(parent=ip.display_formatter)
+
+ >>> ip.display_formatter.formatters[LLMFormatter.format_type] = llm_formatter
+
+Now any class that define `_repr_llm_` will return a x-vendor/llm as part of
+it's display data:
+
+ >>> class A:
+ ...
+ ... def _repr_llm_(self, *kwargs):
+ ... return 'This a A'
+ ...
+
+ >>> ip.display_formatter.format(A())
+ ({'text/plain': '<IPython.core.formatters.A at ...>', 'x-vendor/llm': 'This a A'}, {})
+
+As usual, you can register methods for third party types (see
+:ref:`third_party_formatting`)
+
+ >>> def llm_int(obj):
+ ... return 'This is the integer %s, in between %s and %s'%(obj, obj-1, obj+1)
+
+ >>> llm_formatter.for_type(int, llm_int)
+
+ >>> ip.display_formatter.format(42)
+ ({'text/plain': '42', 'x-vendor/llm': 'This is the integer 42, in between 41 and 43'}, {})
+
+
Inheritance diagram:
.. inheritance-diagram:: IPython.core.formatters
@@ -37,9 +92,10 @@ class DisplayFormatter(Configurable):
active_types = List(Unicode(),
help="""List of currently active mime-types to display.
You can use this to set a white-list for formats to display.
-
+
Most users will not need to change this value.
- """).tag(config=True)
+ """,
+ ).tag(config=True)
@default('active_types')
def _active_types_default(self):
@@ -144,7 +200,7 @@ class DisplayFormatter(Configurable):
"""
format_dict = {}
md_dict = {}
-
+
if self.ipython_display_formatter(obj):
# object handled itself, don't proceed
return {}, {}
@@ -176,18 +232,18 @@ class DisplayFormatter(Configurable):
continue
if exclude and format_type in exclude:
continue
-
+
md = None
try:
data = formatter(obj)
except:
# FIXME: log the exception
raise
-
+
# formatters can return raw data or (data, metadata)
if isinstance(data, tuple) and len(data) == 2:
data, md = data
-
+
if data is not None:
format_dict[format_type] = data
if md is not None:
@@ -252,7 +308,7 @@ class FormatterABC(metaclass=abc.ABCMeta):
# Is the formatter enabled...
enabled = True
-
+
@abc.abstractmethod
def __call__(self, obj):
"""Return a JSON'able representation of the object.
@@ -278,12 +334,15 @@ def _get_type(obj):
return getattr(obj, '__class__', None) or type(obj)
-_raise_key_error = Sentinel('_raise_key_error', __name__,
-"""
+_raise_key_error = Sentinel(
+ "_raise_key_error",
+ __name__,
+ """
Special value to raise a KeyError
Raise KeyError in `BaseFormatter.pop` if passed as the default value to `pop`
-""")
+""",
+)
class BaseFormatter(Configurable):
@@ -329,7 +388,7 @@ class BaseFormatter(Configurable):
# The deferred-import type-specific printers.
# Map (modulename, classname) pairs to the format functions.
deferred_printers = Dict().tag(config=True)
-
+
@catch_format_error
def __call__(self, obj):
"""Compute the format for an object."""
@@ -348,7 +407,7 @@ class BaseFormatter(Configurable):
return None
else:
return None
-
+
def __contains__(self, typ):
"""map in to lookup_by_type"""
try:
@@ -357,7 +416,7 @@ class BaseFormatter(Configurable):
return False
else:
return True
-
+
def _check_return(self, r, obj):
"""Check that a return value is appropriate
@@ -372,7 +431,7 @@ class BaseFormatter(Configurable):
(self.format_type, type(r), self._return_type, _safe_repr(obj)),
FormatterWarning
)
-
+
def lookup(self, obj):
"""Look up the formatter for a given instance.
@@ -395,7 +454,7 @@ class BaseFormatter(Configurable):
return self.singleton_printers[obj_id]
# then lookup by type
return self.lookup_by_type(_get_type(obj))
-
+
def lookup_by_type(self, typ):
"""Look up the registered formatter for a type.
@@ -426,7 +485,7 @@ class BaseFormatter(Configurable):
for cls in pretty._get_mro(typ):
if cls in self.type_printers or self._in_deferred_types(cls):
return self.type_printers[cls]
-
+
# If we have reached here, the lookup failed.
raise KeyError("No registered printer for {0!r}".format(typ))
@@ -459,15 +518,15 @@ class BaseFormatter(Configurable):
if isinstance(typ, str):
type_module, type_name = typ.rsplit('.', 1)
return self.for_type_by_name(type_module, type_name, func)
-
+
try:
oldfunc = self.lookup_by_type(typ)
except KeyError:
oldfunc = None
-
+
if func is not None:
self.type_printers[typ] = func
-
+
return oldfunc
def for_type_by_name(self, type_module, type_name, func=None):
@@ -501,16 +560,16 @@ class BaseFormatter(Configurable):
this will be the previous value (to enable restoring later).
"""
key = (type_module, type_name)
-
+
try:
oldfunc = self.lookup_by_type("%s.%s" % key)
except KeyError:
oldfunc = None
-
+
if func is not None:
self.deferred_printers[key] = func
return oldfunc
-
+
def pop(self, typ, default=_raise_key_error):
"""Pop a formatter for the given type.
@@ -529,7 +588,7 @@ class BaseFormatter(Configurable):
------
KeyError if the type is not registered and default is not specified.
"""
-
+
if isinstance(typ, str):
typ_key = tuple(typ.rsplit('.',1))
if typ_key not in self.deferred_printers:
@@ -599,14 +658,14 @@ class PlainTextFormatter(BaseFormatter):
# This subclass ignores this attribute as it always need to return
# something.
enabled = Bool(True).tag(config=False)
-
+
max_seq_length = Integer(pretty.MAX_SEQ_LENGTH,
help="""Truncate large collections (lists, dicts, tuples, sets) to this size.
-
+
Set to 0 to disable truncation.
- """
+ """,
).tag(config=True)
-
+
# Look for a _repr_pretty_ methods to use for pretty printing.
print_method = ObjectName('_repr_pretty_')
@@ -775,7 +834,7 @@ class PNGFormatter(BaseFormatter):
format_type = Unicode('image/png')
print_method = ObjectName('_repr_png_')
-
+
_return_type = (bytes, str)
@@ -829,7 +888,7 @@ class JSONFormatter(BaseFormatter):
_return_type = (list, dict)
print_method = ObjectName('_repr_json_')
-
+
def _check_return(self, r, obj):
"""Check that a return value is appropriate
@@ -887,19 +946,19 @@ class PDFFormatter(BaseFormatter):
class IPythonDisplayFormatter(BaseFormatter):
"""An escape-hatch Formatter for objects that know how to display themselves.
-
+
To define the callables that compute the representation of your
objects, define a :meth:`_ipython_display_` method or use the :meth:`for_type`
or :meth:`for_type_by_name` methods to register functions that handle
this. Unlike mime-type displays, this method should not return anything,
instead calling any appropriate display methods itself.
-
+
This display formatter has highest priority.
If it fires, no other display formatter will be called.
Prior to IPython 6.1, `_ipython_display_` was the only way to display custom mime-types
without registering a new Formatter.
-
+
IPython 6.1 introduces `_repr_mimebundle_` for displaying custom mime-types,
so `_ipython_display_` should only be used for objects that require unusual
display patterns, such as multiple display calls.
@@ -943,7 +1002,7 @@ class MimeBundleFormatter(BaseFormatter):
"""
print_method = ObjectName('_repr_mimebundle_')
_return_type = dict
-
+
def _check_return(self, r, obj):
r = super(MimeBundleFormatter, self)._check_return(r, obj)
# always return (data, metadata):
diff --git a/contrib/python/ipython/py3/IPython/core/guarded_eval.py b/contrib/python/ipython/py3/IPython/core/guarded_eval.py
index 39fe853f58..628fe2fbcc 100644
--- a/contrib/python/ipython/py3/IPython/core/guarded_eval.py
+++ b/contrib/python/ipython/py3/IPython/core/guarded_eval.py
@@ -44,20 +44,17 @@ else:
@undoc
class HasGetItem(Protocol):
- def __getitem__(self, key) -> None:
- ...
+ def __getitem__(self, key) -> None: ...
@undoc
class InstancesHaveGetItem(Protocol):
- def __call__(self, *args, **kwargs) -> HasGetItem:
- ...
+ def __call__(self, *args, **kwargs) -> HasGetItem: ...
@undoc
class HasGetAttr(Protocol):
- def __getattr__(self, key) -> None:
- ...
+ def __getattr__(self, key) -> None: ...
@undoc
@@ -329,9 +326,9 @@ class EvaluationContext(NamedTuple):
#: Global namespace
globals: dict
#: Evaluation policy identifier
- evaluation: Literal[
- "forbidden", "minimal", "limited", "unsafe", "dangerous"
- ] = "forbidden"
+ evaluation: Literal["forbidden", "minimal", "limited", "unsafe", "dangerous"] = (
+ "forbidden"
+ )
#: Whether the evaluation of code takes place inside of a subscript.
#: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``.
in_subscript: bool = False
diff --git a/contrib/python/ipython/py3/IPython/core/inputsplitter.py b/contrib/python/ipython/py3/IPython/core/inputsplitter.py
index 092f21408a..b20dfb16ca 100644
--- a/contrib/python/ipython/py3/IPython/core/inputsplitter.py
+++ b/contrib/python/ipython/py3/IPython/core/inputsplitter.py
@@ -15,6 +15,7 @@ and stores the results.
For more details, see the class docstrings below.
"""
+
from __future__ import annotations
from warnings import warn
diff --git a/contrib/python/ipython/py3/IPython/core/inputtransformer2.py b/contrib/python/ipython/py3/IPython/core/inputtransformer2.py
index 949cf383e2..15d3f0630a 100644
--- a/contrib/python/ipython/py3/IPython/core/inputtransformer2.py
+++ b/contrib/python/ipython/py3/IPython/core/inputtransformer2.py
@@ -395,7 +395,10 @@ def _tr_quote2(content):
def _tr_paren(content):
"Translate lines escaped with a slash: /"
- name, _, args = content.partition(' ')
+ name, _, args = content.partition(" ")
+ if name == "":
+ raise SyntaxError(f'"{ESC_SHELL}" must be followed by a callable name')
+
return '%s(%s)' % (name, ", ".join(args.split()))
tr = { ESC_SHELL : 'get_ipython().system({!r})'.format,
diff --git a/contrib/python/ipython/py3/IPython/core/magics/basic.py b/contrib/python/ipython/py3/IPython/core/magics/basic.py
index 3e3eb2d3f8..11b569328a 100644
--- a/contrib/python/ipython/py3/IPython/core/magics/basic.py
+++ b/contrib/python/ipython/py3/IPython/core/magics/basic.py
@@ -461,7 +461,7 @@ Currently the magic system has the following functions:""",
ptformatter.pprint = False
disp_formatter.active_types = ['text/plain']
- shell.magic('xmode Plain')
+ shell.run_line_magic("xmode", "Plain")
else:
# turn off
shell.separate_in = dstore.rc_separate_in
@@ -472,7 +472,7 @@ Currently the magic system has the following functions:""",
ptformatter.pprint = dstore.rc_pprint
disp_formatter.active_types = dstore.rc_active_types
- shell.magic('xmode ' + dstore.xmode)
+ shell.run_line_magic("xmode", dstore.xmode)
# mode here is the state before we switch; switch_doctest_mode takes
# the mode we're switching to.
diff --git a/contrib/python/ipython/py3/IPython/core/magics/logging.py b/contrib/python/ipython/py3/IPython/core/magics/logging.py
index b6b8d8a5af..81b167545c 100644
--- a/contrib/python/ipython/py3/IPython/core/magics/logging.py
+++ b/contrib/python/ipython/py3/IPython/core/magics/logging.py
@@ -83,14 +83,14 @@ class LoggingMagics(Magics):
log 'raw' input. Normally, IPython's logs contain the processed
input, so that user lines are logged in their final form, converted
into valid Python. For example, %Exit is logged as
- _ip.magic("Exit"). If the -r flag is given, all input is logged
+ _ip.run_line_magic("Exit"). If the -r flag is given, all input is logged
exactly as typed, with no transformations applied.
-t
put timestamps before each input line logged (these are put in
comments).
- -q
+ -q
suppress output of logstate message when logging is invoked
"""
diff --git a/contrib/python/ipython/py3/IPython/core/prompts.py b/contrib/python/ipython/py3/IPython/core/prompts.py
index 7fd218d37a..105ff17f75 100644
--- a/contrib/python/ipython/py3/IPython/core/prompts.py
+++ b/contrib/python/ipython/py3/IPython/core/prompts.py
@@ -2,9 +2,11 @@
"""Being removed
"""
+
class LazyEvaluate(object):
"""This is used for formatting strings with values that need to be updated
at that time, such as the current time or working directory."""
+
def __init__(self, func, *args, **kwargs):
self.func = func
self.args = args
@@ -16,6 +18,6 @@ class LazyEvaluate(object):
def __str__(self):
return str(self())
-
+
def __format__(self, format_spec):
return format(self(), format_spec)
diff --git a/contrib/python/ipython/py3/IPython/core/release.py b/contrib/python/ipython/py3/IPython/core/release.py
index d9eb28aa95..702e037a24 100644
--- a/contrib/python/ipython/py3/IPython/core/release.py
+++ b/contrib/python/ipython/py3/IPython/core/release.py
@@ -16,7 +16,7 @@
# release. 'dev' as a _version_extra string means this is a development
# version
_version_major = 8
-_version_minor = 29
+_version_minor = 30
_version_patch = 0
_version_extra = ".dev"
# _version_extra = "rc1"
diff --git a/contrib/python/ipython/py3/IPython/external/qt_loaders.py b/contrib/python/ipython/py3/IPython/external/qt_loaders.py
index 6058ee5a9a..87b716582a 100644
--- a/contrib/python/ipython/py3/IPython/external/qt_loaders.py
+++ b/contrib/python/ipython/py3/IPython/external/qt_loaders.py
@@ -8,6 +8,7 @@ bindings, which is unstable and likely to crash
This is used primarily by qt and qt_for_kernel, and shouldn't
be accessed directly from the outside
"""
+
import importlib.abc
import sys
import os
diff --git a/contrib/python/ipython/py3/IPython/lib/__init__.py b/contrib/python/ipython/py3/IPython/lib/__init__.py
index 94b8ade4ec..cf8ccb0415 100644
--- a/contrib/python/ipython/py3/IPython/lib/__init__.py
+++ b/contrib/python/ipython/py3/IPython/lib/__init__.py
@@ -3,9 +3,9 @@
Extra capabilities for IPython
"""
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Copyright (C) 2008-2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
diff --git a/contrib/python/ipython/py3/IPython/lib/clipboard.py b/contrib/python/ipython/py3/IPython/lib/clipboard.py
index 1d691a7ea6..e0bf80b075 100644
--- a/contrib/python/ipython/py3/IPython/lib/clipboard.py
+++ b/contrib/python/ipython/py3/IPython/lib/clipboard.py
@@ -1,5 +1,6 @@
""" Utilities for accessing the platform's clipboard.
"""
+
import os
import subprocess
diff --git a/contrib/python/ipython/py3/IPython/lib/latextools.py b/contrib/python/ipython/py3/IPython/lib/latextools.py
index f2aa572884..7bea589a51 100644
--- a/contrib/python/ipython/py3/IPython/lib/latextools.py
+++ b/contrib/python/ipython/py3/IPython/lib/latextools.py
@@ -18,7 +18,6 @@ from IPython.utils.process import find_cmd, FindCmdError
from traitlets.config import get_config
from traitlets.config.configurable import SingletonConfigurable
from traitlets import List, Bool, Unicode
-from IPython.utils.py3compat import cast_unicode
class LaTeXTool(SingletonConfigurable):
@@ -58,8 +57,9 @@ class LaTeXTool(SingletonConfigurable):
).tag(config=True)
-def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black',
- scale=1.0):
+def latex_to_png(
+ s: str, encode=False, backend=None, wrap=False, color="Black", scale=1.0
+):
"""Render a LaTeX string to PNG.
Parameters
@@ -80,7 +80,7 @@ def latex_to_png(s, encode=False, backend=None, wrap=False, color='Black',
None is returned when the backend cannot be used.
"""
- s = cast_unicode(s)
+ assert isinstance(s, str)
allowed_backends = LaTeXTool.instance().backends
if backend is None:
backend = allowed_backends[0]
diff --git a/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py b/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py
index 75c2a25ccb..f0ea034a6d 100644
--- a/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py
+++ b/contrib/python/ipython/py3/IPython/sphinxext/custom_doctests.py
@@ -107,7 +107,7 @@ def float_doctest(sphinx_shell, args, input_lines, found, submitted):
try:
rtol = float(args[2])
atol = float(args[3])
- except IndexError as e:
+ except IndexError:
e = ("Both `rtol` and `atol` must be specified "
"if either are specified: {0}".format(args))
raise IndexError(e) from e
diff --git a/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py b/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py
index 88357a5113..5561ad63b8 100644
--- a/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py
+++ b/contrib/python/ipython/py3/IPython/sphinxext/ipython_directive.py
@@ -174,7 +174,7 @@ To Do
# Authors
# =======
-#
+#
# - John D Hunter: original author.
# - Fernando Perez: refactoring, documentation, cleanups, port to 0.11.
# - VáclavŠmilauer <eudoxos-AT-arcig.cz>: Prompt generalizations.
@@ -196,6 +196,7 @@ import ast
import warnings
import shutil
from io import StringIO
+from typing import Any, Dict, Set
# Third-party
from docutils.parsers.rst import directives
@@ -425,7 +426,7 @@ class EmbeddedSphinxShell(object):
source_dir = self.source_dir
saveargs = decorator.split(' ')
filename = saveargs[1]
- # insert relative path to image file in source
+ # insert relative path to image file in source
# as absolute path for Sphinx
# sphinx expects a posix path, even on Windows
path = pathlib.Path(savefig_dir, filename)
@@ -901,21 +902,22 @@ class EmbeddedSphinxShell(object):
class IPythonDirective(Directive):
- has_content = True
- required_arguments = 0
- optional_arguments = 4 # python, suppress, verbatim, doctest
- final_argumuent_whitespace = True
- option_spec = { 'python': directives.unchanged,
- 'suppress' : directives.flag,
- 'verbatim' : directives.flag,
- 'doctest' : directives.flag,
- 'okexcept': directives.flag,
- 'okwarning': directives.flag
- }
+ has_content: bool = True
+ required_arguments: int = 0
+ optional_arguments: int = 4 # python, suppress, verbatim, doctest
+ final_argumuent_whitespace: bool = True
+ option_spec: Dict[str, Any] = {
+ "python": directives.unchanged,
+ "suppress": directives.flag,
+ "verbatim": directives.flag,
+ "doctest": directives.flag,
+ "okexcept": directives.flag,
+ "okwarning": directives.flag,
+ }
shell = None
- seen_docs = set()
+ seen_docs: Set = set()
def get_config_options(self):
# contains sphinx configuration variables
diff --git a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
index 40e2c9a669..ef4f5cd3f6 100644
--- a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
+++ b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
@@ -52,6 +52,7 @@ from .prompts import Prompts, ClassicPrompts, RichPromptDisplayHook
from .ptutils import IPythonPTCompleter, IPythonPTLexer
from .shortcuts import (
KEY_BINDINGS,
+ UNASSIGNED_ALLOWED_COMMANDS,
create_ipython_shortcuts,
create_identifier,
RuntimeBinding,
@@ -508,19 +509,25 @@ class TerminalInteractiveShell(InteractiveShell):
# rebuild the bindings list from scratch
key_bindings = create_ipython_shortcuts(self)
- # for now we only allow adding shortcuts for commands which are already
- # registered; this is a security precaution.
- known_commands = {
+ # for now we only allow adding shortcuts for a specific set of
+ # commands; this is a security precution.
+ allowed_commands = {
create_identifier(binding.command): binding.command
for binding in KEY_BINDINGS
}
+ allowed_commands.update(
+ {
+ create_identifier(command): command
+ for command in UNASSIGNED_ALLOWED_COMMANDS
+ }
+ )
shortcuts_to_skip = []
shortcuts_to_add = []
for shortcut in user_shortcuts:
command_id = shortcut["command"]
- if command_id not in known_commands:
- allowed_commands = "\n - ".join(known_commands)
+ if command_id not in allowed_commands:
+ allowed_commands = "\n - ".join(allowed_commands)
raise ValueError(
f"{command_id} is not a known shortcut command."
f" Allowed commands are: \n - {allowed_commands}"
@@ -544,7 +551,7 @@ class TerminalInteractiveShell(InteractiveShell):
new_keys = shortcut.get("new_keys", None)
new_filter = shortcut.get("new_filter", None)
- command = known_commands[command_id]
+ command = allowed_commands[command_id]
creating_new = shortcut.get("create", False)
modifying_existing = not creating_new and (
@@ -586,12 +593,14 @@ class TerminalInteractiveShell(InteractiveShell):
RuntimeBinding(
command,
keys=new_keys or old_keys,
- filter=filter_from_string(new_filter)
- if new_filter is not None
- else (
- old_filter
- if old_filter is not None
- else filter_from_string("always")
+ filter=(
+ filter_from_string(new_filter)
+ if new_filter is not None
+ else (
+ old_filter
+ if old_filter is not None
+ else filter_from_string("always")
+ )
),
)
)
diff --git a/contrib/python/ipython/py3/IPython/terminal/shortcuts/__init__.py b/contrib/python/ipython/py3/IPython/terminal/shortcuts/__init__.py
index 12890f4ab6..ba6d405526 100644
--- a/contrib/python/ipython/py3/IPython/terminal/shortcuts/__init__.py
+++ b/contrib/python/ipython/py3/IPython/terminal/shortcuts/__init__.py
@@ -628,3 +628,11 @@ KEY_BINDINGS = [
*SIMPLE_CONTROL_BINDINGS,
*ALT_AND_COMOBO_CONTROL_BINDINGS,
]
+
+UNASSIGNED_ALLOWED_COMMANDS = [
+ nc.beginning_of_buffer,
+ nc.end_of_buffer,
+ nc.end_of_line,
+ nc.forward_word,
+ nc.unix_line_discard,
+]
diff --git a/contrib/python/ipython/py3/IPython/terminal/shortcuts/auto_match.py b/contrib/python/ipython/py3/IPython/terminal/shortcuts/auto_match.py
index 6c2b1ef70c..6095558bbf 100644
--- a/contrib/python/ipython/py3/IPython/terminal/shortcuts/auto_match.py
+++ b/contrib/python/ipython/py3/IPython/terminal/shortcuts/auto_match.py
@@ -4,6 +4,7 @@ Utilities function for keybinding with prompt toolkit.
This will be bound to specific key press and filter modes,
like whether we are in edit mode, and whether the completer is open.
"""
+
import re
from prompt_toolkit.key_binding import KeyPressEvent
diff --git a/contrib/python/ipython/py3/IPython/utils/_process_cli.py b/contrib/python/ipython/py3/IPython/utils/_process_cli.py
index 86e918a8d0..e303202e8a 100644
--- a/contrib/python/ipython/py3/IPython/utils/_process_cli.py
+++ b/contrib/python/ipython/py3/IPython/utils/_process_cli.py
@@ -35,6 +35,7 @@ def system(cmd):
# Start up process:
reg = System.Diagnostics.Process.Start(psi)
+
def getoutput(cmd):
"""
getoutput(cmd) should work in a cli environment on Mac OSX, Linux,
@@ -53,6 +54,7 @@ def getoutput(cmd):
error = myError.ReadToEnd()
return output
+
def check_pid(pid):
"""
Check if a process with the given PID (pid) exists
@@ -66,4 +68,4 @@ def check_pid(pid):
return True
except System.ArgumentException:
# process with given pid isn't running
- return False
+ return False
diff --git a/contrib/python/ipython/py3/IPython/utils/_process_win32.py b/contrib/python/ipython/py3/IPython/utils/_process_win32.py
index 36fb092d7b..7a95978085 100644
--- a/contrib/python/ipython/py3/IPython/utils/_process_win32.py
+++ b/contrib/python/ipython/py3/IPython/utils/_process_win32.py
@@ -170,7 +170,7 @@ try:
# not really a cl-arg, fallback on _process_common
return py_arg_split(commandline, posix=posix, strict=strict)
argvn = c_int()
- result_pointer = CommandLineToArgvW(py3compat.cast_unicode(commandline.lstrip()), ctypes.byref(argvn))
+ result_pointer = CommandLineToArgvW(commandline.lstrip(), ctypes.byref(argvn))
result_array_type = LPCWSTR * argvn.value
result = [arg for arg in result_array_type.from_address(ctypes.addressof(result_pointer.contents))]
retval = LocalFree(result_pointer)
diff --git a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
index 261309bb28..b11405ec5f 100644
--- a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
+++ b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
@@ -1,2 +1,2 @@
# GENERATED BY setup.py
-commit = "af19fb054"
+commit = "a8541f5c2"
diff --git a/contrib/python/ipython/py3/IPython/utils/dir2.py b/contrib/python/ipython/py3/IPython/utils/dir2.py
index 9f19b2dd84..5dc699a92d 100644
--- a/contrib/python/ipython/py3/IPython/utils/dir2.py
+++ b/contrib/python/ipython/py3/IPython/utils/dir2.py
@@ -41,7 +41,7 @@ def dir2(obj):
# TypeError: dir(obj) does not return a list
words = set()
- if safe_hasattr(obj, '__class__'):
+ if safe_hasattr(obj, "__class__"):
words |= set(dir(obj.__class__))
# filter out non-string attributes which may be stuffed by dir() calls
@@ -62,7 +62,7 @@ def get_real_method(obj, name):
Returns the method or None.
"""
try:
- canary = getattr(obj, '_ipython_canary_method_should_not_exist_', None)
+ canary = getattr(obj, "_ipython_canary_method_should_not_exist_", None)
except Exception:
return None
diff --git a/contrib/python/ipython/py3/IPython/utils/sysinfo.py b/contrib/python/ipython/py3/IPython/utils/sysinfo.py
index 347123fd53..c93eaef096 100644
--- a/contrib/python/ipython/py3/IPython/utils/sysinfo.py
+++ b/contrib/python/ipython/py3/IPython/utils/sysinfo.py
@@ -99,7 +99,7 @@ def get_sys_info() -> dict:
path = Path(__file__, "..").resolve().parent
return pkg_info(str(path))
-def sys_info():
+def sys_info() -> str:
"""Return useful information about IPython and the system, as a string.
Examples
diff --git a/contrib/python/ipython/py3/patches/02-fix-ya.make.patch b/contrib/python/ipython/py3/patches/02-fix-ya.make.patch
index 828df69945..9a69b86080 100644
--- a/contrib/python/ipython/py3/patches/02-fix-ya.make.patch
+++ b/contrib/python/ipython/py3/patches/02-fix-ya.make.patch
@@ -1,8 +1,8 @@
--- contrib/python/ipython/py3/.dist-info/METADATA (index)
+++ contrib/python/ipython/py3/.dist-info/METADATA (working tree)
@@ -31,1 +31,1 @@ Classifier: Programming Language :: Python :: 3 :: Only
--Requires-Dist: jedi >=0.16
-+Requires-Dist: jedi >=0.13
+-Requires-Dist: jedi>=0.16
++Requires-Dist: jedi>=0.13
--- contrib/python/ipython/py3/ya.make (index)
+++ contrib/python/ipython/py3/ya.make (working tree)
@@ -17,1 +17,0 @@ PEERDIR(
diff --git a/contrib/python/ipython/py3/ya.make b/contrib/python/ipython/py3/ya.make
index 71ae1e14b1..134a881949 100644
--- a/contrib/python/ipython/py3/ya.make
+++ b/contrib/python/ipython/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(8.29.0)
+VERSION(8.30.0)
LICENSE(BSD-3-Clause)