aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3/IPython
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-01-09 18:56:40 +0100
committerGitHub <noreply@github.com>2024-01-09 18:56:40 +0100
commite95f266d2a3e48e62015220588a4fd73d5d5a5cb (patch)
treea8a784b6931fe52ad5f511cfef85af14e5f63991 /contrib/python/ipython/py3/IPython
parent50a65e3b48a82d5b51f272664da389f2e0b0c99a (diff)
downloadydb-e95f266d2a3e48e62015220588a4fd73d5d5a5cb.tar.gz
Library import 6 (#888)
Diffstat (limited to 'contrib/python/ipython/py3/IPython')
-rw-r--r--contrib/python/ipython/py3/IPython/__init__.py3
-rw-r--r--contrib/python/ipython/py3/IPython/core/completer.py2
-rw-r--r--contrib/python/ipython/py3/IPython/core/interactiveshell.py5
-rw-r--r--contrib/python/ipython/py3/IPython/core/oinspect.py5
-rw-r--r--contrib/python/ipython/py3/IPython/core/release.py4
-rw-r--r--contrib/python/ipython/py3/IPython/terminal/interactiveshell.py15
-rw-r--r--contrib/python/ipython/py3/IPython/terminal/prompts.py27
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/tz.py50
9 files changed, 89 insertions, 24 deletions
diff --git a/contrib/python/ipython/py3/IPython/__init__.py b/contrib/python/ipython/py3/IPython/__init__.py
index 3322562a16..b7235481f2 100644
--- a/contrib/python/ipython/py3/IPython/__init__.py
+++ b/contrib/python/ipython/py3/IPython/__init__.py
@@ -26,9 +26,10 @@ import sys
#-----------------------------------------------------------------------------
# Don't forget to also update setup.py when this changes!
-if sys.version_info < (3, 9):
+if sys.version_info < (3, 10):
raise ImportError(
"""
+IPython 8.19+ supports Python 3.10 and above, following SPEC0.
IPython 8.13+ supports Python 3.9 and above, following NEP 29.
IPython 8.0-8.12 supports Python 3.8 and above, following NEP 29.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
diff --git a/contrib/python/ipython/py3/IPython/core/completer.py b/contrib/python/ipython/py3/IPython/core/completer.py
index cc5f6c4270..8e2bb7f810 100644
--- a/contrib/python/ipython/py3/IPython/core/completer.py
+++ b/contrib/python/ipython/py3/IPython/core/completer.py
@@ -2237,7 +2237,7 @@ class IPCompleter(Completer):
self, cursor_column: int, cursor_line: int, text: str
) -> Iterator[_JediCompletionLike]:
"""
- Return a list of :any:`jedi.api.Completion`s object from a ``text`` and
+ Return a list of :any:`jedi.api.Completion`\\s object from a ``text`` and
cursor position.
Parameters
diff --git a/contrib/python/ipython/py3/IPython/core/interactiveshell.py b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
index 67727404f9..1a73571f78 100644
--- a/contrib/python/ipython/py3/IPython/core/interactiveshell.py
+++ b/contrib/python/ipython/py3/IPython/core/interactiveshell.py
@@ -2639,7 +2639,10 @@ class InteractiveShell(SingletonConfigurable):
"""
cmd = self.var_expand(cmd, depth=1)
# warn if there is an IPython magic alternative.
- main_cmd = cmd.split()[0]
+ if cmd == "":
+ main_cmd = ""
+ else:
+ main_cmd = cmd.split()[0]
has_magic_alternatives = ("pip", "conda", "cd")
if main_cmd in has_magic_alternatives:
diff --git a/contrib/python/ipython/py3/IPython/core/oinspect.py b/contrib/python/ipython/py3/IPython/core/oinspect.py
index d77a732267..a8be281975 100644
--- a/contrib/python/ipython/py3/IPython/core/oinspect.py
+++ b/contrib/python/ipython/py3/IPython/core/oinspect.py
@@ -28,10 +28,7 @@ import warnings
from typing import Any, Optional, Dict, Union, List, Tuple
-if sys.version_info <= (3, 10):
- from typing_extensions import TypeAlias
-else:
- from typing import TypeAlias
+from typing import TypeAlias
# IPython's own
from IPython.core import page
diff --git a/contrib/python/ipython/py3/IPython/core/release.py b/contrib/python/ipython/py3/IPython/core/release.py
index d012ec426b..70d5a675a3 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 = 18
-_version_patch = 1
+_version_minor = 19
+_version_patch = 0
_version_extra = ".dev"
# _version_extra = "rc1"
_version_extra = "" # Uncomment this for full releases
diff --git a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
index 997fd82250..532287f5e7 100644
--- a/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
+++ b/contrib/python/ipython/py3/IPython/terminal/interactiveshell.py
@@ -588,6 +588,17 @@ class TerminalInteractiveShell(InteractiveShell):
help="Display the current vi mode (when using vi editing mode)."
).tag(config=True)
+ prompt_line_number_format = Unicode(
+ "",
+ help="The format for line numbering, will be passed `line` (int, 1 based)"
+ " the current line number and `rel_line` the relative line number."
+ " for example to display both you can use the following template string :"
+ " c.TerminalInteractiveShell.prompt_line_number_format='{line: 4d}/{rel_line:+03d} | '"
+ " This will display the current line number, with leading space and a width of at least 4"
+ " character, as well as the relative line number 0 padded and always with a + or - sign."
+ " Note that when using Emacs mode the prompt of the first line may not update.",
+ ).tag(config=True)
+
@observe('term_title')
def init_term_title(self, change=None):
# Enable or disable the terminal title.
@@ -736,7 +747,7 @@ class TerminalInteractiveShell(InteractiveShell):
def get_message():
return PygmentsTokens(self.prompts.in_prompt_tokens())
- if self.editing_mode == 'emacs':
+ if self.editing_mode == "emacs" and self.prompt_line_number_format == "":
# with emacs mode the prompt is (usually) static, so we call only
# the function once. With VI mode it can toggle between [ins] and
# [nor] so we can't precompute.
@@ -753,7 +764,7 @@ class TerminalInteractiveShell(InteractiveShell):
"message": get_message,
"prompt_continuation": (
lambda width, lineno, is_soft_wrap: PygmentsTokens(
- self.prompts.continuation_prompt_tokens(width)
+ self.prompts.continuation_prompt_tokens(width, lineno=lineno)
)
),
"multiline": True,
diff --git a/contrib/python/ipython/py3/IPython/terminal/prompts.py b/contrib/python/ipython/py3/IPython/terminal/prompts.py
index 3f5c07b980..ca56d91a40 100644
--- a/contrib/python/ipython/py3/IPython/terminal/prompts.py
+++ b/contrib/python/ipython/py3/IPython/terminal/prompts.py
@@ -25,11 +25,21 @@ class Prompts(object):
return '['+mode+'] '
return ''
+ def current_line(self) -> int:
+ if self.shell.pt_app is not None:
+ return self.shell.pt_app.default_buffer.document.cursor_position_row or 0
+ return 0
def in_prompt_tokens(self):
return [
- (Token.Prompt, self.vi_mode() ),
- (Token.Prompt, 'In ['),
+ (Token.Prompt, self.vi_mode()),
+ (
+ Token.Prompt,
+ self.shell.prompt_line_number_format.format(
+ line=1, rel_line=-self.current_line()
+ ),
+ ),
+ (Token.Prompt, "In ["),
(Token.PromptNum, str(self.shell.execution_count)),
(Token.Prompt, ']: '),
]
@@ -37,11 +47,20 @@ class Prompts(object):
def _width(self):
return fragment_list_width(self.in_prompt_tokens())
- def continuation_prompt_tokens(self, width=None):
+ def continuation_prompt_tokens(self, width=None, *, lineno=None):
if width is None:
width = self._width()
+ line = lineno + 1 if lineno is not None else 0
+ prefix = " " * len(
+ self.vi_mode()
+ ) + self.shell.prompt_line_number_format.format(
+ line=line, rel_line=line - self.current_line() - 1
+ )
return [
- (Token.Prompt, (' ' * (width - 5)) + '...: '),
+ (
+ Token.Prompt,
+ prefix + (" " * (width - len(prefix) - 5)) + "...: ",
+ ),
]
def rewrite_prompt_tokens(self):
diff --git a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
index 8cb62ae3d0..02820dc9c1 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 = "49914f938"
+commit = "dc4369111"
diff --git a/contrib/python/ipython/py3/IPython/utils/tz.py b/contrib/python/ipython/py3/IPython/utils/tz.py
index dbe1e8e732..ba1199d274 100644
--- a/contrib/python/ipython/py3/IPython/utils/tz.py
+++ b/contrib/python/ipython/py3/IPython/utils/tz.py
@@ -3,29 +3,56 @@
Timezone utilities
Just UTC-awareness right now
+
+Deprecated since IPython 8.19.0.
"""
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Copyright (C) 2013 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.
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Imports
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+import warnings
from datetime import tzinfo, timedelta, datetime
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Code
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+__all__ = ["tzUTC", "utc_aware", "utcfromtimestamp", "utcnow"]
+
+
# constant for zero offset
ZERO = timedelta(0)
+
+def __getattr__(name):
+ if name not in __all__:
+ err = f"IPython.utils.tz is deprecated and has no attribute {name}"
+ raise AttributeError(err)
+
+ _warn_deprecated()
+
+ return getattr(name)
+
+
+def _warn_deprecated():
+ msg = "The module `IPython.utils.tz` is deprecated and will be completely removed."
+ warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
+
+
class tzUTC(tzinfo):
- """tzinfo object for UTC (zero offset)"""
+ """tzinfo object for UTC (zero offset)
+
+ Deprecated since IPython 8.19.0.
+ """
+
+ _warn_deprecated()
def utcoffset(self, d):
return ZERO
@@ -38,11 +65,18 @@ UTC = tzUTC() # type: ignore[abstract]
def utc_aware(unaware):
- """decorator for adding UTC tzinfo to datetime's utcfoo methods"""
+ """decorator for adding UTC tzinfo to datetime's utcfoo methods
+
+ Deprecated since IPython 8.19.0.
+ """
+
def utc_method(*args, **kwargs):
+ _warn_deprecated()
dt = unaware(*args, **kwargs)
return dt.replace(tzinfo=UTC)
+
return utc_method
+
utcfromtimestamp = utc_aware(datetime.utcfromtimestamp)
utcnow = utc_aware(datetime.utcnow)