aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py3
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-01-04 15:53:08 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-01-04 16:07:11 +0300
commit0aaf156b641766ba2f26c5c54f2aa02016bb51f4 (patch)
tree4aefc952c87e1dc424ec9002f05412ce4b2b2598 /contrib/python/ipython/py3
parenta719ba289f03a96a2ad4e96605e57870e50a992b (diff)
downloadydb-0aaf156b641766ba2f26c5c54f2aa02016bb51f4.tar.gz
Intermediate changes
commit_hash:52e193336c733675186ea9e84a61825375cdab04
Diffstat (limited to 'contrib/python/ipython/py3')
-rw-r--r--contrib/python/ipython/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/ipython/py3/IPython/core/completer.py66
-rw-r--r--contrib/python/ipython/py3/IPython/core/debugger.py2
-rw-r--r--contrib/python/ipython/py3/IPython/core/inputtransformer.py37
-rw-r--r--contrib/python/ipython/py3/IPython/core/release.py2
-rw-r--r--contrib/python/ipython/py3/IPython/utils/_sysinfo.py2
-rw-r--r--contrib/python/ipython/py3/ya.make2
7 files changed, 89 insertions, 24 deletions
diff --git a/contrib/python/ipython/py3/.dist-info/METADATA b/contrib/python/ipython/py3/.dist-info/METADATA
index 08d01e914e..b6a222768c 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.30.0
+Version: 8.31.0
Summary: IPython: Productive Interactive Computing
Author: The IPython Development Team
Author-email: ipython-dev@python.org
diff --git a/contrib/python/ipython/py3/IPython/core/completer.py b/contrib/python/ipython/py3/IPython/core/completer.py
index 8260975765..db5de81019 100644
--- a/contrib/python/ipython/py3/IPython/core/completer.py
+++ b/contrib/python/ipython/py3/IPython/core/completer.py
@@ -184,6 +184,7 @@ import glob
import inspect
import itertools
import keyword
+import ast
import os
import re
import string
@@ -347,7 +348,7 @@ def provisionalcompleter(action='ignore'):
yield
-def has_open_quotes(s):
+def has_open_quotes(s: str) -> Union[str, bool]:
"""Return whether a string has open quotes.
This simply counts whether the number of quote characters of either type in
@@ -368,7 +369,7 @@ def has_open_quotes(s):
return False
-def protect_filename(s, protectables=PROTECTABLES):
+def protect_filename(s: str, protectables: str = PROTECTABLES) -> str:
"""Escape a string to protect certain characters."""
if set(s) & set(protectables):
if sys.platform == "win32":
@@ -449,11 +450,11 @@ def completions_sorting_key(word):
if word.startswith('%%'):
# If there's another % in there, this is something else, so leave it alone
- if not "%" in word[2:]:
+ if "%" not in word[2:]:
word = word[2:]
prio2 = 2
elif word.startswith('%'):
- if not "%" in word[1:]:
+ if "%" not in word[1:]:
word = word[1:]
prio2 = 1
@@ -752,7 +753,7 @@ def completion_matcher(
priority: Optional[float] = None,
identifier: Optional[str] = None,
api_version: int = 1,
-):
+) -> Callable[[Matcher], Matcher]:
"""Adds attributes describing the matcher.
Parameters
@@ -961,8 +962,8 @@ class CompletionSplitter(object):
def split_line(self, line, cursor_pos=None):
"""Split a line of text with a cursor at the given position.
"""
- l = line if cursor_pos is None else line[:cursor_pos]
- return self._delim_re.split(l)[-1]
+ cut_line = line if cursor_pos is None else line[:cursor_pos]
+ return self._delim_re.split(cut_line)[-1]
@@ -1141,8 +1142,13 @@ class Completer(Configurable):
"""
return self._attr_matches(text)[0]
- def _attr_matches(self, text, include_prefix=True) -> Tuple[Sequence[str], str]:
- m2 = re.match(r"(.+)\.(\w*)$", self.line_buffer)
+ # we simple attribute matching with normal identifiers.
+ _ATTR_MATCH_RE = re.compile(r"(.+)\.(\w*)$")
+
+ def _attr_matches(
+ self, text: str, include_prefix: bool = True
+ ) -> Tuple[Sequence[str], str]:
+ m2 = self._ATTR_MATCH_RE.match(self.line_buffer)
if not m2:
return [], ""
expr, attr = m2.group(1, 2)
@@ -1204,6 +1210,30 @@ class Completer(Configurable):
"." + attr,
)
+ def _trim_expr(self, code: str) -> str:
+ """
+ Trim the code until it is a valid expression and not a tuple;
+
+ return the trimmed expression for guarded_eval.
+ """
+ while code:
+ code = code[1:]
+ try:
+ res = ast.parse(code)
+ except SyntaxError:
+ continue
+
+ assert res is not None
+ if len(res.body) != 1:
+ continue
+ expr = res.body[0].value
+ if isinstance(expr, ast.Tuple) and not code[-1] == ")":
+ # we skip implicit tuple, like when trimming `fun(a,b`<completion>
+ # as `a,b` would be a tuple, and we actually expect to get only `b`
+ continue
+ return code
+ return ""
+
def _evaluate_expr(self, expr):
obj = not_found
done = False
@@ -1225,14 +1255,14 @@ class Completer(Configurable):
# e.g. user starts `(d[`, so we get `expr = '(d'`,
# where parenthesis is not closed.
# TODO: make this faster by reusing parts of the computation?
- expr = expr[1:]
+ expr = self._trim_expr(expr)
return obj
def get__all__entries(obj):
"""returns the strings in the __all__ attribute"""
try:
words = getattr(obj, '__all__')
- except:
+ except Exception:
return []
return [w for w in words if isinstance(w, str)]
@@ -1447,7 +1477,7 @@ def match_dict_keys(
try:
if not str_key.startswith(prefix_str):
continue
- except (AttributeError, TypeError, UnicodeError) as e:
+ except (AttributeError, TypeError, UnicodeError):
# Python 3+ TypeError on b'a'.startswith('a') or vice-versa
continue
@@ -1495,7 +1525,7 @@ def cursor_to_position(text:str, line:int, column:int)->int:
lines = text.split('\n')
assert line <= len(lines), '{} <= {}'.format(str(line), str(len(lines)))
- return sum(len(l) + 1 for l in lines[:line]) + column
+ return sum(len(line) + 1 for line in lines[:line]) + column
def position_to_cursor(text:str, offset:int)->Tuple[int, int]:
"""
@@ -2113,7 +2143,7 @@ class IPCompleter(Completer):
result["suppress"] = is_magic_prefix and bool(result["completions"])
return result
- def magic_matches(self, text: str):
+ def magic_matches(self, text: str) -> List[str]:
"""Match magics.
.. deprecated:: 8.6
@@ -2470,7 +2500,8 @@ class IPCompleter(Completer):
# parenthesis before the cursor
# e.g. for "foo (1+bar(x), pa<cursor>,a=1)", the candidate is "foo"
tokens = regexp.findall(self.text_until_cursor)
- iterTokens = reversed(tokens); openPar = 0
+ iterTokens = reversed(tokens)
+ openPar = 0
for token in iterTokens:
if token == ')':
@@ -2490,7 +2521,8 @@ class IPCompleter(Completer):
try:
ids.append(next(iterTokens))
if not isId(ids[-1]):
- ids.pop(); break
+ ids.pop()
+ break
if not next(iterTokens) == '.':
break
except StopIteration:
@@ -3216,7 +3248,7 @@ class IPCompleter(Completer):
else:
api_version = _get_matcher_api_version(matcher)
raise ValueError(f"Unsupported API version {api_version}")
- except:
+ except BaseException:
# Show the ugly traceback if the matcher causes an
# exception, but do NOT crash the kernel!
sys.excepthook(*sys.exc_info())
diff --git a/contrib/python/ipython/py3/IPython/core/debugger.py b/contrib/python/ipython/py3/IPython/core/debugger.py
index 84d3de8c5b..e06bd56318 100644
--- a/contrib/python/ipython/py3/IPython/core/debugger.py
+++ b/contrib/python/ipython/py3/IPython/core/debugger.py
@@ -550,7 +550,7 @@ class Pdb(OldPdb):
So if frame is self.current_frame we instead return self.curframe_locals
"""
- if frame is self.curframe:
+ if frame is getattr(self, "curframe", None):
return self.curframe_locals
else:
return frame.f_locals
diff --git a/contrib/python/ipython/py3/IPython/core/inputtransformer.py b/contrib/python/ipython/py3/IPython/core/inputtransformer.py
index bb1061e8dc..5229be4322 100644
--- a/contrib/python/ipython/py3/IPython/core/inputtransformer.py
+++ b/contrib/python/ipython/py3/IPython/core/inputtransformer.py
@@ -9,6 +9,7 @@ import abc
import functools
import re
import tokenize
+import warnings
from tokenize import untokenize, TokenError
from io import StringIO
@@ -42,7 +43,16 @@ ESC_SEQUENCES = [ESC_SHELL, ESC_SH_CAP, ESC_HELP ,\
class InputTransformer(metaclass=abc.ABCMeta):
"""Abstract base class for line-based input transformers."""
-
+
+ def __init__(self):
+ warnings.warn(
+ "`InputTransformer` has been deprecated since IPython 7.0"
+ " and emit a warnig since IPython 8.31, it"
+ " will be removed in the future",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+
@abc.abstractmethod
def push(self, line):
"""Send a line of input to the transformer, returning the transformed
@@ -78,6 +88,14 @@ class InputTransformer(metaclass=abc.ABCMeta):
class StatelessInputTransformer(InputTransformer):
"""Wrapper for a stateless input transformer implemented as a function."""
def __init__(self, func):
+ super().__init__()
+ warnings.warn(
+ "`StatelessInputTransformer` has been deprecated since IPython 7.0"
+ " and emit a warnig since IPython 8.31, it"
+ " will be removed in the future",
+ DeprecationWarning,
+ stacklevel=2,
+ )
self.func = func
def __repr__(self):
@@ -96,6 +114,14 @@ class CoroutineInputTransformer(InputTransformer):
"""Wrapper for an input transformer implemented as a coroutine."""
def __init__(self, coro, **kwargs):
# Prime it
+ super().__init__()
+ warnings.warn(
+ "`CoroutineInputTransformer` has been deprecated since IPython 7.0"
+ " and emit a warnig since IPython 8.31, it"
+ " will be removed in the future",
+ DeprecationWarning,
+ stacklevel=2,
+ )
self.coro = coro(**kwargs)
next(self.coro)
@@ -122,6 +148,13 @@ class TokenInputTransformer(InputTransformer):
return an iterable which can be passed to tokenize.untokenize().
"""
def __init__(self, func):
+ warnings.warn(
+ "`CoroutineInputTransformer` has been deprecated since IPython 7.0"
+ " and emit a warnig since IPython 8.31, it"
+ " will be removed in the future",
+ DeprecationWarning,
+ stacklevel=2,
+ )
self.func = func
self.buf = []
self.reset_tokenizer()
@@ -167,7 +200,7 @@ class TokenInputTransformer(InputTransformer):
class assemble_python_lines(TokenInputTransformer):
def __init__(self):
- super(assemble_python_lines, self).__init__(None)
+ super().__init__(None)
def output(self, tokens):
return self.reset()
diff --git a/contrib/python/ipython/py3/IPython/core/release.py b/contrib/python/ipython/py3/IPython/core/release.py
index 702e037a24..06917bb8ae 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 = 30
+_version_minor = 31
_version_patch = 0
_version_extra = ".dev"
# _version_extra = "rc1"
diff --git a/contrib/python/ipython/py3/IPython/utils/_sysinfo.py b/contrib/python/ipython/py3/IPython/utils/_sysinfo.py
index b11405ec5f..44fbbc4530 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 = "a8541f5c2"
+commit = "22d6a1c16"
diff --git a/contrib/python/ipython/py3/ya.make b/contrib/python/ipython/py3/ya.make
index 134a881949..950e693736 100644
--- a/contrib/python/ipython/py3/ya.make
+++ b/contrib/python/ipython/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(8.30.0)
+VERSION(8.31.0)
LICENSE(BSD-3-Clause)