aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-03-12 17:24:47 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-03-12 17:34:45 +0300
commite84602b8f2b95d10d45eb11369ae7d627339c881 (patch)
tree028524c9f076a9c4019a8d78d4a30685b7626c99 /contrib
parente98c636d759bf6f106a2b90142041bb9d4f1e33f (diff)
downloadydb-e84602b8f2b95d10d45eb11369ae7d627339c881.tar.gz
Intermediate changes
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/ipython/py3/.dist-info/METADATA46
-rw-r--r--contrib/python/ipython/py3/IPython/core/alias.py5
-rw-r--r--contrib/python/ipython/py3/IPython/core/completer.py2
-rw-r--r--contrib/python/ipython/py3/IPython/core/completerlib.py12
-rw-r--r--contrib/python/ipython/py3/IPython/core/displaypub.py25
-rw-r--r--contrib/python/ipython/py3/IPython/core/formatters.py13
-rw-r--r--contrib/python/ipython/py3/IPython/core/history.py41
-rw-r--r--contrib/python/ipython/py3/IPython/core/historyapp.py67
-rw-r--r--contrib/python/ipython/py3/IPython/core/inputsplitter.py11
-rw-r--r--contrib/python/ipython/py3/IPython/core/interactiveshell.py73
-rw-r--r--contrib/python/ipython/py3/IPython/core/magic.py4
-rw-r--r--contrib/python/ipython/py3/IPython/core/magics/ast_mod.py20
-rw-r--r--contrib/python/ipython/py3/IPython/core/magics/script.py3
-rw-r--r--contrib/python/ipython/py3/IPython/core/oinspect.py186
-rw-r--r--contrib/python/ipython/py3/IPython/core/prefilter.py13
-rw-r--r--contrib/python/ipython/py3/IPython/core/release.py4
-rw-r--r--contrib/python/ipython/py3/IPython/core/ultratb.py10
-rw-r--r--contrib/python/ipython/py3/IPython/extensions/storemagic.py2
-rw-r--r--contrib/python/ipython/py3/IPython/lib/pretty.py8
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_process_emscripten.py23
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/path.py20
-rw-r--r--contrib/python/ipython/py3/IPython/utils/process.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/text.py28
-rw-r--r--contrib/python/ipython/py3/ya.make3
25 files changed, 411 insertions, 212 deletions
diff --git a/contrib/python/ipython/py3/.dist-info/METADATA b/contrib/python/ipython/py3/.dist-info/METADATA
index 5efeded1e1..11836decd6 100644
--- a/contrib/python/ipython/py3/.dist-info/METADATA
+++ b/contrib/python/ipython/py3/.dist-info/METADATA
@@ -1,11 +1,11 @@
Metadata-Version: 2.1
Name: ipython
-Version: 8.21.0
+Version: 8.22.2
Summary: IPython: Productive Interactive Computing
-Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev@python.org
License: BSD-3-Clause
+Project-URL: Homepage, https://ipython.org
Project-URL: Documentation, https://ipython.readthedocs.io/
Project-URL: Funding, https://numfocus.org/
Project-URL: Source, https://github.com/ipython/ipython
@@ -32,37 +32,14 @@ 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
+Requires-Dist: traitlets >=5.13.0
Requires-Dist: typing-extensions ; python_version < "3.10"
Requires-Dist: exceptiongroup ; python_version < "3.11"
-Requires-Dist: pexpect >4.3 ; sys_platform != "win32"
+Requires-Dist: pexpect >4.3 ; sys_platform != "win32" and sys_platform != "emscripten"
Requires-Dist: colorama ; sys_platform == "win32"
Provides-Extra: all
-Requires-Dist: black ; extra == 'all'
-Requires-Dist: ipykernel ; extra == 'all'
-Requires-Dist: setuptools >=18.5 ; extra == 'all'
-Requires-Dist: sphinx >=1.3 ; extra == 'all'
-Requires-Dist: sphinx-rtd-theme ; extra == 'all'
-Requires-Dist: docrepr ; extra == 'all'
-Requires-Dist: matplotlib ; extra == 'all'
-Requires-Dist: stack-data ; extra == 'all'
-Requires-Dist: typing-extensions ; extra == 'all'
-Requires-Dist: exceptiongroup ; extra == 'all'
-Requires-Dist: pytest <8 ; extra == 'all'
-Requires-Dist: pytest-asyncio <0.22 ; extra == 'all'
-Requires-Dist: testpath ; extra == 'all'
-Requires-Dist: pickleshare ; extra == 'all'
-Requires-Dist: nbconvert ; extra == 'all'
-Requires-Dist: nbformat ; extra == 'all'
-Requires-Dist: ipywidgets ; extra == 'all'
-Requires-Dist: notebook ; extra == 'all'
-Requires-Dist: ipyparallel ; extra == 'all'
-Requires-Dist: qtconsole ; extra == 'all'
-Requires-Dist: curio ; extra == 'all'
-Requires-Dist: matplotlib !=3.2.0 ; extra == 'all'
-Requires-Dist: numpy >=1.23 ; extra == 'all'
-Requires-Dist: pandas ; extra == 'all'
-Requires-Dist: trio ; extra == 'all'
+Requires-Dist: ipython[black,doc,kernel,nbconvert,nbformat,notebook,parallel,qtconsole,terminal] ; extra == 'all'
+Requires-Dist: ipython[test,test_extra] ; extra == 'all'
Provides-Extra: black
Requires-Dist: black ; extra == 'black'
Provides-Extra: doc
@@ -70,15 +47,13 @@ Requires-Dist: ipykernel ; extra == 'doc'
Requires-Dist: setuptools >=18.5 ; extra == 'doc'
Requires-Dist: sphinx >=1.3 ; extra == 'doc'
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
+Requires-Dist: sphinxcontrib-jquery ; extra == 'doc'
Requires-Dist: docrepr ; extra == 'doc'
Requires-Dist: matplotlib ; extra == 'doc'
Requires-Dist: stack-data ; extra == 'doc'
Requires-Dist: typing-extensions ; extra == 'doc'
Requires-Dist: exceptiongroup ; extra == 'doc'
-Requires-Dist: pytest <8 ; extra == 'doc'
-Requires-Dist: pytest-asyncio <0.22 ; extra == 'doc'
-Requires-Dist: testpath ; extra == 'doc'
-Requires-Dist: pickleshare ; extra == 'doc'
+Requires-Dist: ipython[test] ; extra == 'doc'
Provides-Extra: kernel
Requires-Dist: ipykernel ; extra == 'kernel'
Provides-Extra: nbconvert
@@ -99,10 +74,7 @@ Requires-Dist: pytest-asyncio <0.22 ; extra == 'test'
Requires-Dist: testpath ; extra == 'test'
Requires-Dist: pickleshare ; extra == 'test'
Provides-Extra: test_extra
-Requires-Dist: pytest <8 ; extra == 'test_extra'
-Requires-Dist: pytest-asyncio <0.22 ; extra == 'test_extra'
-Requires-Dist: testpath ; extra == 'test_extra'
-Requires-Dist: pickleshare ; 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'
diff --git a/contrib/python/ipython/py3/IPython/core/alias.py b/contrib/python/ipython/py3/IPython/core/alias.py
index 52843b3d77..845e6b7d31 100644
--- a/contrib/python/ipython/py3/IPython/core/alias.py
+++ b/contrib/python/ipython/py3/IPython/core/alias.py
@@ -30,6 +30,9 @@ from .error import UsageError
from traitlets import List, Instance
from logging import error
+import typing as t
+
+
#-----------------------------------------------------------------------------
# Utilities
#-----------------------------------------------------------------------------
@@ -37,7 +40,7 @@ from logging import error
# This is used as the pattern for calls to split_user_input.
shell_line_split = re.compile(r'^(\s*)()(\S+)(.*$)')
-def default_aliases():
+def default_aliases() -> t.List[t.Tuple[str, str]]:
"""Return list of shell aliases to auto-define.
"""
# Note: the aliases defined here should be safe to use on a kernel
diff --git a/contrib/python/ipython/py3/IPython/core/completer.py b/contrib/python/ipython/py3/IPython/core/completer.py
index 8e2bb7f810..09a033a227 100644
--- a/contrib/python/ipython/py3/IPython/core/completer.py
+++ b/contrib/python/ipython/py3/IPython/core/completer.py
@@ -2551,7 +2551,7 @@ class IPCompleter(Completer):
EvaluationContext(
globals=self.global_namespace,
locals=self.namespace,
- evaluation=self.evaluation,
+ evaluation=self.evaluation, # type: ignore
in_subscript=True,
),
)
diff --git a/contrib/python/ipython/py3/IPython/core/completerlib.py b/contrib/python/ipython/py3/IPython/core/completerlib.py
index a970ba6968..de6c4249b0 100644
--- a/contrib/python/ipython/py3/IPython/core/completerlib.py
+++ b/contrib/python/ipython/py3/IPython/core/completerlib.py
@@ -67,6 +67,7 @@ magic_run_re = re.compile(r'.*(\.ipy|\.ipynb|\.py[w]?)$')
# Local utilities
#-----------------------------------------------------------------------------
+
arcadia_rootmodules_cache = None
arcadia_modules_cache = None
@@ -111,7 +112,7 @@ def arcadia_get_root_modules():
return arcadia_rootmodules_cache
-def module_list(path):
+def module_list(path: str) -> List[str]:
"""
Return the list containing the names of the modules available in the given
folder.
@@ -127,7 +128,7 @@ def module_list(path):
# Build a list of all files in the directory and all files
# in its subdirectories. For performance reasons, do not
# recurse more than one level into subdirectories.
- files = []
+ files: List[str] = []
for root, dirs, nondirs in os.walk(path, followlinks=True):
subdir = root[len(path)+1:]
if subdir:
@@ -138,8 +139,8 @@ def module_list(path):
else:
try:
- files = list(zipimporter(path)._files.keys())
- except:
+ files = list(zipimporter(path)._files.keys()) # type: ignore
+ except Exception:
files = []
# Build a list of modules which match the import_re regex.
@@ -242,6 +243,9 @@ def try_import(mod: str, only_modules=False) -> List[str]:
if m_is_init:
file_ = m.__file__
+ file_path = os.path.dirname(file_) # type: ignore
+ if file_path is not None:
+ completions.extend(module_list(file_path))
completions.extend(arcadia_module_list(mod))
completions_set = {c for c in completions if isinstance(c, str)}
completions_set.discard('__init__')
diff --git a/contrib/python/ipython/py3/IPython/core/displaypub.py b/contrib/python/ipython/py3/IPython/core/displaypub.py
index 74028ec79e..ed6a7082e7 100644
--- a/contrib/python/ipython/py3/IPython/core/displaypub.py
+++ b/contrib/python/ipython/py3/IPython/core/displaypub.py
@@ -24,7 +24,9 @@ from traitlets import List
# This used to be defined here - it is imported for backwards compatibility
from .display_functions import publish_display_data
-#-----------------------------------------------------------------------------
+import typing as t
+
+# -----------------------------------------------------------------------------
# Main payload class
#-----------------------------------------------------------------------------
@@ -103,9 +105,9 @@ class DisplayPublisher(Configurable):
rather than creating a new output.
"""
- handlers = {}
+ handlers: t.Dict = {}
if self.shell is not None:
- handlers = getattr(self.shell, 'mime_renderers', {})
+ handlers = getattr(self.shell, "mime_renderers", {})
for mime, handler in handlers.items():
if mime in data:
@@ -125,11 +127,20 @@ class DisplayPublisher(Configurable):
class CapturingDisplayPublisher(DisplayPublisher):
"""A DisplayPublisher that stores"""
- outputs = List()
- def publish(self, data, metadata=None, source=None, *, transient=None, update=False):
- self.outputs.append({'data':data, 'metadata':metadata,
- 'transient':transient, 'update':update})
+ outputs: List = List()
+
+ def publish(
+ self, data, metadata=None, source=None, *, transient=None, update=False
+ ):
+ self.outputs.append(
+ {
+ "data": data,
+ "metadata": metadata,
+ "transient": transient,
+ "update": update,
+ }
+ )
def clear_output(self, wait=False):
super(CapturingDisplayPublisher, self).clear_output(wait)
diff --git a/contrib/python/ipython/py3/IPython/core/formatters.py b/contrib/python/ipython/py3/IPython/core/formatters.py
index 15cf703c2a..9e59e23de1 100644
--- a/contrib/python/ipython/py3/IPython/core/formatters.py
+++ b/contrib/python/ipython/py3/IPython/core/formatters.py
@@ -53,20 +53,23 @@ class DisplayFormatter(Configurable):
else:
formatter.enabled = False
- ipython_display_formatter = ForwardDeclaredInstance('FormatterABC')
- @default('ipython_display_formatter')
+ ipython_display_formatter = ForwardDeclaredInstance("FormatterABC") # type: ignore
+
+ @default("ipython_display_formatter")
def _default_formatter(self):
return IPythonDisplayFormatter(parent=self)
- mimebundle_formatter = ForwardDeclaredInstance('FormatterABC')
- @default('mimebundle_formatter')
+ mimebundle_formatter = ForwardDeclaredInstance("FormatterABC") # type: ignore
+
+ @default("mimebundle_formatter")
def _default_mime_formatter(self):
return MimeBundleFormatter(parent=self)
# A dict of formatter whose keys are format types (MIME types) and whose
# values are subclasses of BaseFormatter.
formatters = Dict()
- @default('formatters')
+
+ @default("formatters")
def _formatters_default(self):
"""Activate the default formatters."""
formatter_classes = [
diff --git a/contrib/python/ipython/py3/IPython/core/history.py b/contrib/python/ipython/py3/IPython/core/history.py
index fb67d158ef..f59ca11916 100644
--- a/contrib/python/ipython/py3/IPython/core/history.py
+++ b/contrib/python/ipython/py3/IPython/core/history.py
@@ -6,15 +6,12 @@
import atexit
import datetime
-from pathlib import Path
import re
import sqlite3
import threading
+from pathlib import Path
-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,
@@ -22,12 +19,16 @@ from traitlets import (
Instance,
Integer,
List,
+ TraitError,
Unicode,
Union,
- TraitError,
default,
observe,
)
+from traitlets.config.configurable import LoggingConfigurable
+
+from IPython.paths import locate_profile
+from IPython.utils.decorators import undoc
#-----------------------------------------------------------------------------
# Classes and functions
@@ -489,8 +490,9 @@ class HistoryManager(HistoryAccessor):
input_hist_parsed = List([""])
input_hist_raw = List([""])
# A list of directories visited during session
- dir_hist = List()
- @default('dir_hist')
+ dir_hist: List = List()
+
+ @default("dir_hist")
def _dir_hist_default(self):
try:
return [Path.cwd()]
@@ -514,8 +516,8 @@ class HistoryManager(HistoryAccessor):
"Values of 1 or less effectively disable caching."
).tag(config=True)
# The input and output caches
- db_input_cache = List()
- db_output_cache = List()
+ db_input_cache: List = List()
+ db_output_cache: List = List()
# History saving in separate thread
save_thread = Instance('IPython.core.history.HistorySavingThread',
@@ -526,10 +528,10 @@ class HistoryManager(HistoryAccessor):
# Variables used to store the three last inputs from the user. On each new
# history update, we populate the user's namespace with these, shifted as
# necessary.
- _i00 = Unicode(u'')
- _i = Unicode(u'')
- _ii = Unicode(u'')
- _iii = Unicode(u'')
+ _i00 = Unicode("")
+ _i = Unicode("")
+ _ii = Unicode("")
+ _iii = Unicode("")
# A regex matching all forms of the exit command, so that we don't store
# them in the history (it's annoying to rewind the first entry and land on
@@ -554,7 +556,14 @@ class HistoryManager(HistoryAccessor):
if self.enabled and self.hist_file != ':memory:':
self.save_thread = HistorySavingThread(self)
- self.save_thread.start()
+ try:
+ self.save_thread.start()
+ except RuntimeError:
+ self.log.error(
+ "Failed to start history saving thread. History will not be saved.",
+ exc_info=True,
+ )
+ self.hist_file = ":memory:"
def _get_hist_file_name(self, profile=None):
"""Get default history file name based on the Shell's profile.
@@ -880,10 +889,10 @@ class HistorySavingThread(threading.Thread):
super(HistorySavingThread, self).__init__(name="IPythonHistorySavingThread")
self.history_manager = history_manager
self.enabled = history_manager.enabled
- atexit.register(self.stop)
@only_when_enabled
def run(self):
+ atexit.register(self.stop)
# We need a separate db connection per thread:
try:
self.db = sqlite3.connect(
@@ -900,6 +909,8 @@ class HistorySavingThread(threading.Thread):
except Exception as e:
print(("The history saving thread hit an unexpected error (%s)."
"History will not be written to the database.") % repr(e))
+ finally:
+ atexit.unregister(self.stop)
def stop(self):
"""This can be called from the main thread to safely stop this thread.
diff --git a/contrib/python/ipython/py3/IPython/core/historyapp.py b/contrib/python/ipython/py3/IPython/core/historyapp.py
index 01a55343f8..85dd9c5c3b 100644
--- a/contrib/python/ipython/py3/IPython/core/historyapp.py
+++ b/contrib/python/ipython/py3/IPython/core/historyapp.py
@@ -32,25 +32,21 @@ This is an handy alias to `ipython history trim --keep=0`
class HistoryTrim(BaseIPythonApplication):
description = trim_hist_help
-
- backup = Bool(False,
- help="Keep the old history file as history.sqlite.<N>"
- ).tag(config=True)
-
- keep = Int(1000,
- help="Number of recent lines to keep in the database."
- ).tag(config=True)
-
- flags = Dict(dict(
- backup = ({'HistoryTrim' : {'backup' : True}},
- backup.help
- )
- ))
- aliases=Dict(dict(
- keep = 'HistoryTrim.keep'
- ))
-
+ backup = Bool(False, help="Keep the old history file as history.sqlite.<N>").tag(
+ config=True
+ )
+
+ keep = Int(1000, help="Number of recent lines to keep in the database.").tag(
+ config=True
+ )
+
+ flags = Dict( # type: ignore
+ dict(backup=({"HistoryTrim": {"backup": True}}, backup.help))
+ )
+
+ aliases = Dict(dict(keep="HistoryTrim.keep")) # type: ignore
+
def start(self):
profile_dir = Path(self.profile_dir.location)
hist_file = profile_dir / "history.sqlite"
@@ -114,34 +110,33 @@ class HistoryTrim(BaseIPythonApplication):
print("Backed up longer history file to", backup_hist_file)
else:
hist_file.unlink()
-
+
new_hist_file.rename(hist_file)
+
class HistoryClear(HistoryTrim):
description = clear_hist_help
- keep = Int(0,
- help="Number of recent lines to keep in the database.")
-
- force = Bool(False,
- help="Don't prompt user for confirmation"
- ).tag(config=True)
-
- flags = Dict(dict(
- force = ({'HistoryClear' : {'force' : True}},
- force.help),
- f = ({'HistoryTrim' : {'force' : True}},
- force.help
+ keep = Int(0, help="Number of recent lines to keep in the database.")
+
+ force = Bool(False, help="Don't prompt user for confirmation").tag(config=True)
+
+ flags = Dict( # type: ignore
+ dict(
+ force=({"HistoryClear": {"force": True}}, force.help),
+ f=({"HistoryTrim": {"force": True}}, force.help),
)
- ))
- aliases = Dict()
+ )
+ aliases = Dict() # type: ignore
def start(self):
- if self.force or ask_yes_no("Really delete all ipython history? ",
- default="no", interrupt="no"):
+ if self.force or ask_yes_no(
+ "Really delete all ipython history? ", default="no", interrupt="no"
+ ):
HistoryTrim.start(self)
+
class HistoryApp(Application):
- name = u'ipython-history'
+ name = "ipython-history"
description = "Manage the IPython history database."
subcommands = Dict(dict(
diff --git a/contrib/python/ipython/py3/IPython/core/inputsplitter.py b/contrib/python/ipython/py3/IPython/core/inputsplitter.py
index 33ed563221..f1ebd96b69 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
@@ -31,7 +32,7 @@ import sys
import tokenize
import warnings
-from typing import List, Tuple, Union, Optional
+from typing import List, Tuple, Union, Optional, TYPE_CHECKING
from types import CodeType
from IPython.core.inputtransformer import (leading_indent,
@@ -52,6 +53,8 @@ from IPython.core.inputtransformer import (ESC_SHELL, ESC_SH_CAP, ESC_HELP,
ESC_HELP2, ESC_MAGIC, ESC_MAGIC2,
ESC_QUOTE, ESC_QUOTE2, ESC_PAREN, ESC_SEQUENCES)
+if TYPE_CHECKING:
+ from typing_extensions import Self
#-----------------------------------------------------------------------------
# Utilities
#-----------------------------------------------------------------------------
@@ -637,9 +640,9 @@ class IPythonInputSplitter(InputSplitter):
# Nothing that calls reset() expects to handle transformer
# errors
pass
-
- def flush_transformers(self):
- def _flush(transform, outs):
+
+ def flush_transformers(self: Self):
+ def _flush(transform, outs: List[str]):
"""yield transformed lines
always strings, never None
diff --git a/contrib/python/ipython/py3/IPython/core/interactiveshell.py b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
index fef5ddc949..12c120625b 100644
--- a/contrib/python/ipython/py3/IPython/core/interactiveshell.py
+++ b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
@@ -47,16 +47,29 @@ except ModuleNotFoundError:
def __init__(self, path):
pass
- def get(self, key, default):
+ def get(self, key, default=None):
warn(
- f"using {key} requires you to install the `pickleshare` library.",
+ f"This is now an optional IPython functionality, using {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)
return default
+ def __getitem__(self, key):
+ warn(
+ f"This is now an optional IPython functionality, using {key} requires you to install the `pickleshare` library.",
+ stacklevel=2,
+ )
+ return None
+
def __setitem__(self, key, value):
warn(
- f"using {key} requires you to install the `pickleshare` library.",
+ f"This is now an optional IPython functionality, setting {key} requires you to install the `pickleshare` library.",
+ stacklevel=2,
+ )
+
+ def __delitem__(self, key):
+ warn(
+ f"This is now an optional IPython functionality, deleting {key} requires you to install the `pickleshare` library.",
stacklevel=2,
)
@@ -268,13 +281,14 @@ class ExecutionInfo(object):
)
-class ExecutionResult(object):
+class ExecutionResult:
"""The result of a call to :meth:`InteractiveShell.run_cell`
Stores information about what took place.
"""
- execution_count = None
- error_before_exec = None
+
+ execution_count: Optional[int] = None
+ error_before_exec: Optional[bool] = None
error_in_exec: Optional[BaseException] = None
info = None
result = None
@@ -314,11 +328,12 @@ class InteractiveShell(SingletonConfigurable):
_instance = None
- ast_transformers = List([], help=
- """
+ ast_transformers: List[ast.NodeTransformer] = List(
+ [],
+ help="""
A list of ast.NodeTransformer subclass instances, which will be applied
to user input before code is run.
- """
+ """,
).tag(config=True)
autocall = Enum((0,1,2), default_value=0, help=
@@ -463,7 +478,8 @@ class InteractiveShell(SingletonConfigurable):
def input_transformers_cleanup(self):
return self.input_transformer_manager.cleanup_transforms
- input_transformers_post = List([],
+ input_transformers_post: List = List(
+ [],
help="A list of string input transformers, to be applied after IPython's "
"own input transformations."
)
@@ -553,14 +569,20 @@ class InteractiveShell(SingletonConfigurable):
).tag(config=True)
# Subcomponents of InteractiveShell
- alias_manager = Instance('IPython.core.alias.AliasManager', allow_none=True)
- prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True)
- builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap', allow_none=True)
- display_trap = Instance('IPython.core.display_trap.DisplayTrap', allow_none=True)
- extension_manager = Instance('IPython.core.extensions.ExtensionManager', allow_none=True)
- payload_manager = Instance('IPython.core.payload.PayloadManager', allow_none=True)
- history_manager = Instance('IPython.core.history.HistoryAccessorBase', allow_none=True)
- magics_manager = Instance('IPython.core.magic.MagicsManager', allow_none=True)
+ alias_manager = Instance("IPython.core.alias.AliasManager", allow_none=True)
+ prefilter_manager = Instance(
+ "IPython.core.prefilter.PrefilterManager", allow_none=True
+ )
+ builtin_trap = Instance("IPython.core.builtin_trap.BuiltinTrap")
+ display_trap = Instance("IPython.core.display_trap.DisplayTrap")
+ extension_manager = Instance(
+ "IPython.core.extensions.ExtensionManager", allow_none=True
+ )
+ payload_manager = Instance("IPython.core.payload.PayloadManager", allow_none=True)
+ history_manager = Instance(
+ "IPython.core.history.HistoryAccessorBase", allow_none=True
+ )
+ magics_manager = Instance("IPython.core.magic.MagicsManager")
profile_dir = Instance('IPython.core.application.ProfileDir', allow_none=True)
@property
@@ -1396,6 +1418,7 @@ class InteractiveShell(SingletonConfigurable):
If new_session is True, a new history session will be opened.
"""
# Clear histories
+ assert self.history_manager is not None
self.history_manager.reset(new_session)
# Reset counter used to index all histories
if new_session:
@@ -1482,6 +1505,7 @@ class InteractiveShell(SingletonConfigurable):
except KeyError as e:
raise NameError("name '%s' is not defined" % varname) from e
# Also check in output history
+ assert self.history_manager is not None
ns_refs.append(self.history_manager.output_hist)
for ns in ns_refs:
to_delete = [n for n, o in ns.items() if o is obj]
@@ -1801,7 +1825,7 @@ class InteractiveShell(SingletonConfigurable):
"""Find an object and return a struct with info about it."""
return self._ofind(oname, namespaces)
- def _inspect(self, meth, oname, namespaces=None, **kw):
+ def _inspect(self, meth, oname: str, namespaces=None, **kw):
"""Generic interface to the inspector system.
This function is meant to be called by pdef, pdoc & friends.
@@ -2409,7 +2433,7 @@ class InteractiveShell(SingletonConfigurable):
res = finder(magic_name)
return res
- def run_line_magic(self, magic_name: str, line, _stack_depth=1):
+ def run_line_magic(self, magic_name: str, line: str, _stack_depth=1):
"""Execute the given line magic.
Parameters
@@ -3256,6 +3280,7 @@ class InteractiveShell(SingletonConfigurable):
# Store raw and processed history
if store_history:
+ assert self.history_manager is not None
self.history_manager.store_inputs(self.execution_count, cell, raw_cell)
if not silent:
self.logger.log(cell, raw_cell)
@@ -3272,8 +3297,6 @@ class InteractiveShell(SingletonConfigurable):
# compiler
compiler = self.compile if shell_futures else self.compiler_class()
- _run_async = False
-
with self.builtin_trap:
cell_name = compiler.cache(cell, self.execution_count, raw_code=raw_cell)
@@ -3319,6 +3342,7 @@ class InteractiveShell(SingletonConfigurable):
self.displayhook.exec_result = None
if store_history:
+ assert self.history_manager is not None
# Write output to the database. Does nothing unless
# history output logging is enabled.
self.history_manager.store_output(self.execution_count)
@@ -3630,8 +3654,6 @@ class InteractiveShell(SingletonConfigurable):
make sense in all contexts, for example a terminal ipython can't
display figures inline.
"""
- from matplotlib_inline.backend_inline import configure_inline_support
-
from IPython.core import pylabtools as pt
gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
@@ -3646,6 +3668,9 @@ class InteractiveShell(SingletonConfigurable):
gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
pt.activate_matplotlib(backend)
+
+ from matplotlib_inline.backend_inline import configure_inline_support
+
configure_inline_support(self, backend)
# Now we must activate the gui pylab wants to use, and fix %run to take
diff --git a/contrib/python/ipython/py3/IPython/core/magic.py b/contrib/python/ipython/py3/IPython/core/magic.py
index 4f9e4e548f..bbb1550a47 100644
--- a/contrib/python/ipython/py3/IPython/core/magic.py
+++ b/contrib/python/ipython/py3/IPython/core/magic.py
@@ -26,6 +26,8 @@ from ..utils.text import dedent
from traitlets import Bool, Dict, Instance, observe
from logging import error
+import typing as t
+
#-----------------------------------------------------------------------------
# Globals
#-----------------------------------------------------------------------------
@@ -36,7 +38,7 @@ from logging import error
# access to the class when they run. See for more details:
# http://stackoverflow.com/questions/2366713/can-a-python-decorator-of-an-instance-method-access-the-class
-magics = dict(line={}, cell={})
+magics: t.Dict = dict(line={}, cell={})
magic_kinds = ('line', 'cell')
magic_spec = ('line', 'cell', 'line_cell')
diff --git a/contrib/python/ipython/py3/IPython/core/magics/ast_mod.py b/contrib/python/ipython/py3/IPython/core/magics/ast_mod.py
index e28b9f1231..fa54791443 100644
--- a/contrib/python/ipython/py3/IPython/core/magics/ast_mod.py
+++ b/contrib/python/ipython/py3/IPython/core/magics/ast_mod.py
@@ -178,11 +178,21 @@ transforming:
__skip_doctest__ = True
-from ast import NodeTransformer, Store, Load, Name, Expr, Assign, Module
+from ast import (
+ NodeTransformer,
+ Store,
+ Load,
+ Name,
+ Expr,
+ Assign,
+ Module,
+ Import,
+ ImportFrom,
+)
import ast
import copy
-from typing import Dict, Optional
+from typing import Dict, Optional, Union
mangle_all = lambda name: False if name in ("__ret__", "__code__") else True
@@ -231,13 +241,13 @@ class Mangler(NodeTransformer):
self.log("Not mangling function arg", arg.arg)
return self.generic_visit(node)
- def visit_ImportFrom(self, node):
+ def visit_ImportFrom(self, node: ImportFrom):
return self._visit_Import_and_ImportFrom(node)
- def visit_Import(self, node):
+ def visit_Import(self, node: Import):
return self._visit_Import_and_ImportFrom(node)
- def _visit_Import_and_ImportFrom(self, node):
+ def _visit_Import_and_ImportFrom(self, node: Union[Import, ImportFrom]):
for alias in node.names:
asname = alias.name if alias.asname is None else alias.asname
if self.predicate(asname):
diff --git a/contrib/python/ipython/py3/IPython/core/magics/script.py b/contrib/python/ipython/py3/IPython/core/magics/script.py
index a858c6489c..0c405ef420 100644
--- a/contrib/python/ipython/py3/IPython/core/magics/script.py
+++ b/contrib/python/ipython/py3/IPython/core/magics/script.py
@@ -86,7 +86,7 @@ class ScriptMagics(Magics):
"""
)
- script_magics = List(
+ script_magics: List = List(
help="""Extra script cell magics to define
This generates simple wrappers of `%%script foo` as `%%foo`.
@@ -95,6 +95,7 @@ class ScriptMagics(Magics):
specify them in script_paths
""",
).tag(config=True)
+
@default('script_magics')
def _script_magics_default(self):
"""default to a common list of programs"""
diff --git a/contrib/python/ipython/py3/IPython/core/oinspect.py b/contrib/python/ipython/py3/IPython/core/oinspect.py
index 9eecf290ae..937e5a9d4b 100644
--- a/contrib/python/ipython/py3/IPython/core/oinspect.py
+++ b/contrib/python/ipython/py3/IPython/core/oinspect.py
@@ -24,9 +24,18 @@ import os
import types
import warnings
-from typing import Any, Optional, Dict, Union, List, Tuple
-from typing import TypeAlias
+from typing import (
+ cast,
+ Any,
+ Optional,
+ Dict,
+ Union,
+ List,
+ TypedDict,
+ TypeAlias,
+ Tuple,
+)
import traitlets
@@ -34,15 +43,12 @@ import traitlets
from IPython.core import page
from IPython.lib.pretty import pretty
from IPython.testing.skipdoctest import skip_doctest
-from IPython.utils import PyColorize
-from IPython.utils import openpy
+from IPython.utils import PyColorize, openpy
from IPython.utils.dir2 import safe_hasattr
from IPython.utils.path import compress_user
from IPython.utils.text import indent
-from IPython.utils.wildcard import list_namespace
-from IPython.utils.wildcard import typestr2type
+from IPython.utils.wildcard import list_namespace, typestr2type
from IPython.utils.coloransi import TermColors
-from IPython.utils.py3compat import cast_unicode
from IPython.utils.colorable import Colorable
from IPython.utils.decorators import undoc
@@ -106,23 +112,78 @@ InspectColors = PyColorize.ANSICodeColors
#****************************************************************************
# Auxiliary functions and objects
-# See the messaging spec for the definition of all these fields. This list
-# effectively defines the order of display
-info_fields = ['type_name', 'base_class', 'string_form', 'namespace',
- 'length', 'file', 'definition', 'docstring', 'source',
- 'init_definition', 'class_docstring', 'init_docstring',
- 'call_def', 'call_docstring',
- # These won't be printed but will be used to determine how to
- # format the object
- 'ismagic', 'isalias', 'isclass', 'found', 'name'
- ]
+class InfoDict(TypedDict):
+ type_name: Optional[str]
+ base_class: Optional[str]
+ string_form: Optional[str]
+ namespace: Optional[str]
+ length: Optional[str]
+ file: Optional[str]
+ definition: Optional[str]
+ docstring: Optional[str]
+ source: Optional[str]
+ init_definition: Optional[str]
+ class_docstring: Optional[str]
+ init_docstring: Optional[str]
+ call_def: Optional[str]
+ call_docstring: Optional[str]
+ subclasses: Optional[str]
+ # These won't be printed but will be used to determine how to
+ # format the object
+ ismagic: bool
+ isalias: bool
+ isclass: bool
+ found: bool
+ name: str
+
+
+_info_fields = list(InfoDict.__annotations__.keys())
+
+
+def __getattr__(name):
+ if name == "info_fields":
+ warnings.warn(
+ "IPython.core.oinspect's `info_fields` is considered for deprecation and may be removed in the Future. ",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ return _info_fields
+
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
+
+
+@dataclass
+class InspectorHookData:
+ """Data passed to the mime hook"""
-def object_info(**kw):
+ obj: Any
+ info: Optional[OInfo]
+ info_dict: InfoDict
+ detail_level: int
+ omit_sections: list[str]
+
+
+@undoc
+def object_info(
+ *,
+ name: str,
+ found: bool,
+ isclass: bool = False,
+ isalias: bool = False,
+ ismagic: bool = False,
+ **kw,
+) -> InfoDict:
"""Make an object info dict with all fields present."""
- infodict = {k:None for k in info_fields}
- infodict.update(kw)
- return infodict
+ infodict = kw
+ infodict = {k: None for k in _info_fields if k not in infodict}
+ infodict["name"] = name # type: ignore
+ infodict["found"] = found # type: ignore
+ infodict["isclass"] = isclass # type: ignore
+ infodict["isalias"] = isalias # type: ignore
+ infodict["ismagic"] = ismagic # type: ignore
+
+ return InfoDict(**infodict) # type:ignore
def get_encoding(obj):
@@ -148,7 +209,8 @@ def get_encoding(obj):
encoding, _lines = openpy.detect_encoding(buffer.readline)
return encoding
-def getdoc(obj) -> Union[str,None]:
+
+def getdoc(obj) -> Union[str, None]:
"""Stable wrapper around inspect.getdoc.
This can't crash because of attribute problems.
@@ -554,8 +616,10 @@ class Inspector(Colorable):
# run contents of file through pager starting at line where the object
# is defined, as long as the file isn't binary and is actually on the
# filesystem.
- if ofile.endswith(('.so', '.dll', '.pyd')):
- print('File %r is binary, not printing.' % ofile)
+ if ofile is None:
+ print("Could not find file for object")
+ elif ofile.endswith((".so", ".dll", ".pyd")):
+ print("File %r is binary, not printing." % ofile)
elif not os.path.isfile(ofile):
print('File %r does not exist, not printing.' % ofile)
else:
@@ -643,7 +707,7 @@ class Inspector(Colorable):
title: str,
key: str,
info,
- omit_sections,
+ omit_sections: List[str],
formatter,
):
"""Append an info value to the unformatted mimebundle being constructed by _make_info_unformatted"""
@@ -740,8 +804,8 @@ class Inspector(Colorable):
oname: str = "",
formatter=None,
info: Optional[OInfo] = None,
- detail_level=0,
- omit_sections=(),
+ detail_level: int = 0,
+ omit_sections: Union[List[str], Tuple[()]] = (),
) -> Bundle:
"""Retrieve an info dict and format it.
@@ -756,11 +820,13 @@ class Inspector(Colorable):
already computed information
detail_level : integer
Granularity of detail level, if set to 1, give more information.
- omit_sections : container[str]
+ omit_sections : list[str]
Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
"""
info_dict = self.info(obj, oname=oname, info=info, detail_level=detail_level)
+ omit_sections = list(omit_sections)
+
bundle = self._make_info_unformatted(
obj,
info_dict,
@@ -768,10 +834,33 @@ class Inspector(Colorable):
detail_level=detail_level,
omit_sections=omit_sections,
)
- for key, hook in self.mime_hooks.items():
- res = hook(obj, info)
- if res is not None:
- bundle[key] = res
+ if self.mime_hooks:
+ hook_data = InspectorHookData(
+ obj=obj,
+ info=info,
+ info_dict=info_dict,
+ detail_level=detail_level,
+ omit_sections=omit_sections,
+ )
+ for key, hook in self.mime_hooks.items(): # type:ignore
+ required_parameters = [
+ parameter
+ for parameter in inspect.signature(hook).parameters.values()
+ if parameter.default != inspect.Parameter.default
+ ]
+ if len(required_parameters) == 1:
+ res = hook(hook_data)
+ else:
+ warnings.warn(
+ "MIME hook format changed in IPython 8.22; hooks should now accept"
+ " a single parameter (InspectorHookData); support for hooks requiring"
+ " two-parameters (obj and info) will be removed in a future version",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ res = hook(obj, info)
+ if res is not None:
+ bundle[key] = res
return self.format_mime(bundle)
def pinfo(
@@ -830,7 +919,7 @@ class Inspector(Colorable):
)
return self.info(obj, oname=oname, info=info, detail_level=detail_level)
- def info(self, obj, oname="", info=None, detail_level=0) -> Dict[str, Any]:
+ def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict:
"""Compute a dict with detailed information about an object.
Parameters
@@ -847,8 +936,7 @@ class Inspector(Colorable):
Returns
-------
- An object info dict with known fields from `info_fields`. Keys are
- strings, values are string or None.
+ An object info dict with known fields from `info_fields` (see `InfoDict`).
"""
if info is None:
@@ -867,8 +955,18 @@ class Inspector(Colorable):
if info and info.parent is not None and hasattr(info.parent, HOOK_NAME):
parents_docs_dict = getattr(info.parent, HOOK_NAME)
parents_docs = parents_docs_dict.get(att_name, None)
- out = dict(
- name=oname, found=True, isalias=isalias, ismagic=ismagic, subclasses=None
+ out: InfoDict = cast(
+ InfoDict,
+ {
+ **{field: None for field in _info_fields},
+ **{
+ "name": oname,
+ "found": True,
+ "isalias": isalias,
+ "ismagic": ismagic,
+ "subclasses": None,
+ },
+ },
)
if parents_docs:
@@ -914,12 +1012,14 @@ class Inspector(Colorable):
if detail_level >= self.str_detail_level:
try:
ostr = str(obj)
- str_head = 'string_form'
- if not detail_level and len(ostr)>string_max:
+ if not detail_level and len(ostr) > string_max:
ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
- ostr = ("\n" + " " * len(str_head.expandtabs())).\
- join(q.strip() for q in ostr.split("\n"))
- out[str_head] = ostr
+ # TODO: `'string_form'.expandtabs()` seems wrong, but
+ # it was (nearly) like this since the first commit ever.
+ ostr = ("\n" + " " * len("string_form".expandtabs())).join(
+ q.strip() for q in ostr.split("\n")
+ )
+ out["string_form"] = ostr
except:
pass
@@ -1054,7 +1154,7 @@ class Inspector(Colorable):
if call_ds:
out['call_docstring'] = call_ds
- return object_info(**out)
+ return out
@staticmethod
def _source_contains_docstring(src, doc):
diff --git a/contrib/python/ipython/py3/IPython/core/prefilter.py b/contrib/python/ipython/py3/IPython/core/prefilter.py
index e7e82e3377..5b1b86c753 100644
--- a/contrib/python/ipython/py3/IPython/core/prefilter.py
+++ b/contrib/python/ipython/py3/IPython/core/prefilter.py
@@ -524,11 +524,14 @@ class AutocallChecker(PrefilterChecker):
class PrefilterHandler(Configurable):
-
- handler_name = Unicode('normal')
- esc_strings = List([])
- shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True)
- prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True)
+ handler_name = Unicode("normal")
+ esc_strings: List = List([])
+ shell = Instance(
+ "IPython.core.interactiveshell.InteractiveShellABC", allow_none=True
+ )
+ prefilter_manager = Instance(
+ "IPython.core.prefilter.PrefilterManager", allow_none=True
+ )
def __init__(self, shell=None, prefilter_manager=None, **kwargs):
super(PrefilterHandler, self).__init__(
diff --git a/contrib/python/ipython/py3/IPython/core/release.py b/contrib/python/ipython/py3/IPython/core/release.py
index f71ee85c08..f668902edf 100644
--- a/contrib/python/ipython/py3/IPython/core/release.py
+++ b/contrib/python/ipython/py3/IPython/core/release.py
@@ -16,8 +16,8 @@
# release. 'dev' as a _version_extra string means this is a development
# version
_version_major = 8
-_version_minor = 21
-_version_patch = 0
+_version_minor = 22
+_version_patch = 2
_version_extra = ".dev"
# _version_extra = "rc1"
_version_extra = "" # Uncomment this for full releases
diff --git a/contrib/python/ipython/py3/IPython/core/ultratb.py b/contrib/python/ipython/py3/IPython/core/ultratb.py
index b0f9e08a3d..382ab1c029 100644
--- a/contrib/python/ipython/py3/IPython/core/ultratb.py
+++ b/contrib/python/ipython/py3/IPython/core/ultratb.py
@@ -743,6 +743,7 @@ class FrameInfo:
lineno: Tuple[int]
# number of context lines to use
context: Optional[int]
+ raw_lines: List[str]
@classmethod
def _from_stack_data_FrameInfo(cls, frame_info):
@@ -777,8 +778,13 @@ class FrameInfo:
# self.lines = []
if sd is None:
- ix = inspect.getsourcelines(frame)
- self.raw_lines = ix[0]
+ try:
+ # return a list of source lines and a starting line number
+ self.raw_lines = inspect.getsourcelines(frame)[0]
+ except OSError:
+ self.raw_lines = [
+ "'Could not get source, probably due dynamically evaluated source code.'"
+ ]
@property
def variables_in_executing_piece(self):
diff --git a/contrib/python/ipython/py3/IPython/extensions/storemagic.py b/contrib/python/ipython/py3/IPython/extensions/storemagic.py
index d9d00f14b9..f3bc8f6c13 100644
--- a/contrib/python/ipython/py3/IPython/extensions/storemagic.py
+++ b/contrib/python/ipython/py3/IPython/extensions/storemagic.py
@@ -145,7 +145,7 @@ class StoreMagics(Magics):
if args:
for arg in args:
try:
- obj = db['autorestore/' + arg]
+ obj = db["autorestore/" + arg]
except KeyError:
try:
restore_aliases(ip, alias=arg)
diff --git a/contrib/python/ipython/py3/IPython/lib/pretty.py b/contrib/python/ipython/py3/IPython/lib/pretty.py
index 2575c3b0a9..631445b24e 100644
--- a/contrib/python/ipython/py3/IPython/lib/pretty.py
+++ b/contrib/python/ipython/py3/IPython/lib/pretty.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
Python advanced pretty printer. This pretty printer is intended to
replace the old `pprint` python module which does not allow developers
@@ -108,6 +107,8 @@ from warnings import warn
from IPython.utils.decorators import undoc
from IPython.utils.py3compat import PYPY
+from typing import Dict
+
__all__ = ['pretty', 'pprint', 'PrettyPrinter', 'RepresentationPrinter',
'for_type', 'for_type_by_name', 'RawText', 'RawStringLiteral', 'CallExpression']
@@ -807,6 +808,7 @@ def _exception_pprint(obj, p, cycle):
#: the exception base
+_exception_base: type
try:
_exception_base = BaseException
except NameError:
@@ -848,8 +850,8 @@ _type_pprinters[range] = _repr_pprint
_type_pprinters[bytes] = _repr_pprint
#: printers for types specified by name
-_deferred_type_pprinters = {
-}
+_deferred_type_pprinters: Dict = {}
+
def for_type(typ, func):
"""
diff --git a/contrib/python/ipython/py3/IPython/utils/_process_emscripten.py b/contrib/python/ipython/py3/IPython/utils/_process_emscripten.py
new file mode 100644
index 0000000000..05dcdc34d5
--- /dev/null
+++ b/contrib/python/ipython/py3/IPython/utils/_process_emscripten.py
@@ -0,0 +1,23 @@
+"""Emscripten-specific implementation of process utilities.
+
+This file is only meant to be imported by process.py, not by end-users.
+"""
+
+
+from ._process_common import arg_split
+
+
+def system(cmd):
+ raise OSError("Not available")
+
+
+def getoutput(cmd):
+ raise OSError("Not available")
+
+
+def check_pid(cmd):
+ raise OSError("Not available")
+
+
+# `arg_split` is still used by magics regardless of whether we are on a posix/windows/emscipten
+__all__ = ["system", "getoutput", "check_pid", "arg_split"]
diff --git a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
index 56568073d7..22be56b84b 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 = "8b1204b6c"
+commit = "d1804576b"
diff --git a/contrib/python/ipython/py3/IPython/utils/path.py b/contrib/python/ipython/py3/IPython/utils/path.py
index ccb70dccd4..cb5be04195 100644
--- a/contrib/python/ipython/py3/IPython/utils/path.py
+++ b/contrib/python/ipython/py3/IPython/utils/path.py
@@ -12,6 +12,7 @@ import errno
import shutil
import random
import glob
+import warnings
from IPython.utils.process import system
@@ -292,7 +293,14 @@ def target_outdated(target,deps):
If target doesn't exist or is older than any file listed in deps, return
true, otherwise return false.
+
+ .. deprecated:: 8.22
"""
+ warnings.warn(
+ "`target_outdated` is deprecated since IPython 8.22 and will be removed in future versions",
+ DeprecationWarning,
+ stacklevel=2,
+ )
try:
target_time = os.path.getmtime(target)
except os.error:
@@ -312,9 +320,17 @@ def target_update(target,deps,cmd):
target_update(target,deps,cmd) -> runs cmd if target is outdated.
This is just a wrapper around target_outdated() which calls the given
- command if target is outdated."""
+ command if target is outdated.
+
+ .. deprecated:: 8.22
+ """
- if target_outdated(target,deps):
+ warnings.warn(
+ "`target_update` is deprecated since IPython 8.22 and will be removed in future versions",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ if target_outdated(target, deps):
system(cmd)
diff --git a/contrib/python/ipython/py3/IPython/utils/process.py b/contrib/python/ipython/py3/IPython/utils/process.py
index 489b7c13d0..f50cf9ba22 100644
--- a/contrib/python/ipython/py3/IPython/utils/process.py
+++ b/contrib/python/ipython/py3/IPython/utils/process.py
@@ -15,6 +15,8 @@ if sys.platform == 'win32':
from ._process_win32 import system, getoutput, arg_split, check_pid
elif sys.platform == 'cli':
from ._process_cli import system, getoutput, arg_split, check_pid
+elif sys.platform == "emscripten":
+ from ._process_emscripten import system, getoutput, arg_split, check_pid
else:
from ._process_posix import system, getoutput, arg_split, check_pid
diff --git a/contrib/python/ipython/py3/IPython/utils/text.py b/contrib/python/ipython/py3/IPython/utils/text.py
index 8f73dca28a..51dcdae5dd 100644
--- a/contrib/python/ipython/py3/IPython/utils/text.py
+++ b/contrib/python/ipython/py3/IPython/utils/text.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
"""
Utilities for working with strings and text.
@@ -11,13 +10,12 @@ Inheritance diagram:
import os
import re
import string
-import sys
import textwrap
import warnings
from string import Formatter
from pathlib import Path
-from typing import List, Dict, Tuple
+from typing import List, Dict, Tuple, Optional, cast
class LSString(str):
@@ -540,11 +538,12 @@ class FullEvalFormatter(Formatter):
"""
# copied from Formatter._vformat with minor changes to allow eval
# and replace the format_spec code with slicing
- def vformat(self, format_string:str, args, kwargs)->str:
+ def vformat(self, format_string: str, args, kwargs) -> str:
result = []
- for literal_text, field_name, format_spec, conversion in \
- self.parse(format_string):
-
+ conversion: Optional[str]
+ for literal_text, field_name, format_spec, conversion in self.parse(
+ format_string
+ ):
# output the literal text
if literal_text:
result.append(literal_text)
@@ -563,7 +562,8 @@ class FullEvalFormatter(Formatter):
obj = eval(field_name, kwargs)
# do any conversion on the resulting object
- obj = self.convert_field(obj, conversion)
+ # type issue in typeshed, fined in https://github.com/python/typeshed/pull/11377
+ obj = self.convert_field(obj, conversion) # type: ignore[arg-type]
# format the object and append to the result
result.append(self.format_field(obj, ''))
@@ -722,7 +722,13 @@ def compute_item_matrix(
return ([[_get_or_default(items, c * nrow + r, default=empty) for c in range(ncol)] for r in range(nrow)], info)
-def columnize(items, row_first=False, separator=" ", displaywidth=80, spread=False):
+def columnize(
+ items: List[str],
+ row_first: bool = False,
+ separator: str = " ",
+ displaywidth: int = 80,
+ spread: bool = False,
+):
"""Transform a list of strings into a single string with columns.
Parameters
@@ -743,7 +749,7 @@ def columnize(items, row_first=False, separator=" ", displaywidth=80, spread=Fa
"""
warnings.warn(
"`columnize` is Pending Deprecation since IPython 8.17."
- "It is considered fro removal in in future version. "
+ "It is considered for removal in future versions. "
"Please open an issue if you believe it should be kept.",
stacklevel=2,
category=PendingDeprecationWarning,
@@ -761,7 +767,7 @@ def columnize(items, row_first=False, separator=" ", displaywidth=80, spread=Fa
separator = separator.ljust(int(info["optimal_separator_width"]))
fmatrix: List[filter[int]] = [filter(None, x) for x in matrix]
sjoin = lambda x: separator.join(
- [y.ljust(w, " ") for y, w in zip(x, info["column_widths"])]
+ [y.ljust(w, " ") for y, w in zip(x, cast(List[int], info["column_widths"]))]
)
return "\n".join(map(sjoin, fmatrix)) + "\n"
diff --git a/contrib/python/ipython/py3/ya.make b/contrib/python/ipython/py3/ya.make
index a53c5172e7..76d52094de 100644
--- a/contrib/python/ipython/py3/ya.make
+++ b/contrib/python/ipython/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(8.21.0)
+VERSION(8.22.2)
LICENSE(BSD-3-Clause)
@@ -174,6 +174,7 @@ PY_SRCS(
IPython/utils/__init__.py
IPython/utils/_process_cli.py
IPython/utils/_process_common.py
+ IPython/utils/_process_emscripten.py
IPython/utils/_process_posix.py
IPython/utils/_process_win32.py
IPython/utils/_process_win32_controller.py