aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-06-14 17:46:04 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-06-14 18:00:06 +0300
commit85f6451860166545196ffa2950aa68be2363733b (patch)
tree4443b7b2465bda4bdc3589314f258329ecaedb38 /contrib/python/prompt-toolkit/py3/prompt_toolkit
parentfa297dd4855aef4bd79faebb48120708d2f9249d (diff)
downloadydb-85f6451860166545196ffa2950aa68be2363733b.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/application/run_in_terminal.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py29
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/base.py23
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py15
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/completion.py24
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/lexer.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/regex_parser.py9
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/validation.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/log.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/protocol.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py5
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/document.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_generator.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py14
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/cli.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/utils.py2
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py6
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py5
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/history.py12
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/ansi_escape_sequences.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/typeahead.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/vt100_parser.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py4
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/basic.py18
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/emacs.py16
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/open_in_editor.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/page_navigation.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/scroll.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/search.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py51
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/defaults.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/digraphs.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_bindings.py13
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py7
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py33
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py11
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dummy.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/margins.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py5
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py6
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py13
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py8
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/utils.py6
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/log.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/mouse_events.py8
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py12
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py8
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/selection.py7
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py34
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/defaults.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/named_colors.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/pygments.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style_transformation.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/token.py3
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/validation.py7
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/__init__.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/dialogs.py1
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/toolbars.py6
90 files changed, 266 insertions, 228 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py
index 82324cb815..7b3e9bbe6d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py
@@ -13,6 +13,7 @@ See the examples directory to learn about the usage.
Probably, to get started, you might also want to have a look at
`prompt_toolkit.shortcuts.prompt`.
"""
+
from __future__ import annotations
import re
@@ -27,7 +28,7 @@ from .formatted_text import ANSI, HTML
from .shortcuts import PromptSession, print_formatted_text, prompt
# Don't forget to update in `docs/conf.py`!
-__version__ = "3.0.43"
+__version__ = "3.0.45"
assert pep440.match(__version__)
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
index d4637811ba..d93c24398a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py
@@ -1621,5 +1621,6 @@ def _restore_sigint_from_ctypes() -> Generator[None, None, None]:
try:
yield
finally:
- signal.signal(signal.SIGINT, sigint)
+ if sigint is not None:
+ signal.signal(signal.SIGINT, sigint)
pythonapi.PyOS_setsig(signal.SIGINT, sigint_os)
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/run_in_terminal.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/run_in_terminal.py
index 1e4da2d9cb..18a3dadeb9 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/run_in_terminal.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/run_in_terminal.py
@@ -1,6 +1,7 @@
"""
Tools for running functions on the terminal above the current application or prompt.
"""
+
from __future__ import annotations
from asyncio import Future, ensure_future
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py
index 98cb4ddd92..73213ba690 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/auto_suggest.py
@@ -11,6 +11,7 @@ because they take too much time, and could potentially block the event loop,
then wrap the :class:`.AutoSuggest` instance into a
:class:`.ThreadedAutoSuggest`.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
@@ -46,7 +47,7 @@ class Suggestion:
self.text = text
def __repr__(self) -> str:
- return "Suggestion(%s)" % self.text
+ return f"Suggestion({self.text})"
class AutoSuggest(metaclass=ABCMeta):
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py
index 100ca78d7b..f5847d4ab9 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py
@@ -2,6 +2,7 @@
Data structures for the Buffer.
It holds the text, cursor position, history, etc...
"""
+
from __future__ import annotations
import asyncio
@@ -85,12 +86,7 @@ class CompletionState:
self.complete_index = complete_index # Position in the `_completions` array.
def __repr__(self) -> str:
- return "{}({!r}, <{!r}> completions, index={!r})".format(
- self.__class__.__name__,
- self.original_document,
- len(self.completions),
- self.complete_index,
- )
+ return f"{self.__class__.__name__}({self.original_document!r}, <{len(self.completions)!r}> completions, index={self.complete_index!r})"
def go_to_index(self, index: int | None) -> None:
"""
@@ -149,12 +145,7 @@ class YankNthArgState:
self.n = n
def __repr__(self) -> str:
- return "{}(history_position={!r}, n={!r}, previous_inserted_word={!r})".format(
- self.__class__.__name__,
- self.history_position,
- self.n,
- self.previous_inserted_word,
- )
+ return f"{self.__class__.__name__}(history_position={self.history_position!r}, n={self.n!r}, previous_inserted_word={self.previous_inserted_word!r})"
BufferEventHandler = Callable[["Buffer"], None]
@@ -188,6 +179,9 @@ class Buffer:
In case of a `PromptSession` for instance, we want to keep the text,
because we will exit the application, and only reset it during the next
run.
+ :param max_number_of_completions: Never display more than this number of
+ completions, even when the completer can produce more (limited by
+ default to 10k for performance).
Events:
@@ -234,12 +228,13 @@ class Buffer:
accept_handler: BufferAcceptHandler | None = None,
read_only: FilterOrBool = False,
multiline: FilterOrBool = True,
+ max_number_of_completions: int = 10000,
on_text_changed: BufferEventHandler | None = None,
on_text_insert: BufferEventHandler | None = None,
on_cursor_position_changed: BufferEventHandler | None = None,
on_completions_changed: BufferEventHandler | None = None,
on_suggestion_set: BufferEventHandler | None = None,
- ):
+ ) -> None:
# Accept both filters and booleans as input.
enable_history_search = to_filter(enable_history_search)
complete_while_typing = to_filter(complete_while_typing)
@@ -261,6 +256,7 @@ class Buffer:
self.enable_history_search = enable_history_search
self.read_only = read_only
self.multiline = multiline
+ self.max_number_of_completions = max_number_of_completions
# Text width. (For wrapping, used by the Vi 'gq' operator.)
self.text_width = 0
@@ -1748,6 +1744,13 @@ class Buffer:
# If the input text changes, abort.
if not proceed():
break
+
+ # Always stop at 10k completions.
+ if (
+ len(complete_state.completions)
+ >= self.max_number_of_completions
+ ):
+ break
finally:
refresh_task.cancel()
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/base.py
index b05275ba63..28cfdcd766 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/clipboard/base.py
@@ -1,6 +1,7 @@
"""
Clipboard for command line interface.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/base.py
index 04a712df7e..3846ef7562 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/base.py
@@ -1,5 +1,5 @@
-"""
-"""
+""" """
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
@@ -66,18 +66,9 @@ class Completion:
def __repr__(self) -> str:
if isinstance(self.display, str) and self.display == self.text:
- return "{}(text={!r}, start_position={!r})".format(
- self.__class__.__name__,
- self.text,
- self.start_position,
- )
+ return f"{self.__class__.__name__}(text={self.text!r}, start_position={self.start_position!r})"
else:
- return "{}(text={!r}, start_position={!r}, display={!r})".format(
- self.__class__.__name__,
- self.text,
- self.start_position,
- self.display,
- )
+ return f"{self.__class__.__name__}(text={self.text!r}, start_position={self.start_position!r}, display={self.display!r})"
def __eq__(self, other: object) -> bool:
if not isinstance(other, Completion):
@@ -156,11 +147,7 @@ class CompleteEvent:
self.completion_requested = completion_requested
def __repr__(self) -> str:
- return "{}(text_inserted={!r}, completion_requested={!r})".format(
- self.__class__.__name__,
- self.text_inserted,
- self.completion_requested,
- )
+ return f"{self.__class__.__name__}(text_inserted={self.text_inserted!r}, completion_requested={self.completion_requested!r})"
class Completer(metaclass=ABCMeta):
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py
index a1d211ab06..8569bd2cff 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/completion/nested.py
@@ -1,6 +1,7 @@
"""
Nestedcompleter for completion of hierarchical data structures.
"""
+
from __future__ import annotations
from typing import Any, Iterable, Mapping, Set, Union
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py
index c947fd5337..38b027cd16 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/__init__.py
@@ -72,6 +72,7 @@ TODO: some examples of:
- How to create an autocompleter from this grammar.
- How to create a parser from this grammar.
"""
+
from __future__ import annotations
from .compiler import compile
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py
index 474f6cfd10..dd558a68a2 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/compiler.py
@@ -38,6 +38,7 @@ Partial matches are possible::
m.variables().get('operator2') # Returns "add"
"""
+
from __future__ import annotations
import re
@@ -96,13 +97,13 @@ class _CompiledGrammar:
counter = [0]
def create_group_func(node: Variable) -> str:
- name = "n%s" % counter[0]
+ name = f"n{counter[0]}"
self._group_names_to_nodes[name] = node.varname
counter[0] += 1
return name
# Compile regex strings.
- self._re_pattern = "^%s$" % self._transform(root_node, create_group_func)
+ self._re_pattern = f"^{self._transform(root_node, create_group_func)}$"
self._re_prefix_patterns = list(
self._transform_prefix(root_node, create_group_func)
)
@@ -153,7 +154,7 @@ class _CompiledGrammar:
def transform(node: Node) -> str:
# Turn `AnyNode` into an OR.
if isinstance(node, AnyNode):
- return "(?:%s)" % "|".join(transform(c) for c in node.children)
+ return "(?:{})".format("|".join(transform(c) for c in node.children))
# Concatenate a `NodeSequence`
elif isinstance(node, NodeSequence):
@@ -311,11 +312,11 @@ class _CompiledGrammar:
yield "".join(result)
elif isinstance(node, Regex):
- yield "(?:%s)?" % node.regex
+ yield f"(?:{node.regex})?"
elif isinstance(node, Lookahead):
if node.negative:
- yield "(?!%s)" % cls._transform(node.childnode, create_group_func)
+ yield f"(?!{cls._transform(node.childnode, create_group_func)})"
else:
# Not sure what the correct semantics are in this case.
# (Probably it's not worth implementing this.)
@@ -349,10 +350,10 @@ class _CompiledGrammar:
)
else:
- raise TypeError("Got %r" % node)
+ raise TypeError(f"Got {node!r}")
for r in transform(root_node):
- yield "^(?:%s)$" % r
+ yield f"^(?:{r})$"
def match(self, string: str) -> Match | None:
"""
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/completion.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/completion.py
index 2e353e8d5a..19ebaad938 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/completion.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/completion.py
@@ -1,6 +1,7 @@
"""
Completer for a regular grammar.
"""
+
from __future__ import annotations
from typing import Iterable
@@ -37,12 +38,10 @@ class GrammarCompleter(Completer):
m = self.compiled_grammar.match_prefix(document.text_before_cursor)
if m:
- completions = self._remove_duplicates(
+ yield from self._remove_duplicates(
self._get_completions_for_match(m, complete_event)
)
- yield from completions
-
def _get_completions_for_match(
self, match: Match, complete_event: CompleteEvent
) -> Iterable[Completion]:
@@ -81,14 +80,21 @@ class GrammarCompleter(Completer):
display_meta=completion.display_meta,
)
- def _remove_duplicates(self, items: Iterable[Completion]) -> list[Completion]:
+ def _remove_duplicates(self, items: Iterable[Completion]) -> Iterable[Completion]:
"""
Remove duplicates, while keeping the order.
(Sometimes we have duplicates, because the there several matches of the
same grammar, each yielding similar completions.)
"""
- result: list[Completion] = []
- for i in items:
- if i not in result:
- result.append(i)
- return result
+
+ def hash_completion(completion: Completion) -> tuple[str, int]:
+ return completion.text, completion.start_position
+
+ yielded_so_far: set[tuple[str, int]] = set()
+
+ for completion in items:
+ hash_value = hash_completion(completion)
+
+ if hash_value not in yielded_so_far:
+ yielded_so_far.add(hash_value)
+ yield completion
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/lexer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/lexer.py
index b0a4debefa..c5434cfdee 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/lexer.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/lexer.py
@@ -2,6 +2,7 @@
`GrammarLexer` is compatible with other lexers and can be used to highlight
the input using a regular grammar with annotations.
"""
+
from __future__ import annotations
from typing import Callable
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/regex_parser.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/regex_parser.py
index a365ba8e04..353e54ff72 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/regex_parser.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/regex_parser.py
@@ -14,6 +14,7 @@ Remarks:
Limitations:
- Lookahead is not supported.
"""
+
from __future__ import annotations
import re
@@ -115,11 +116,7 @@ class Variable(Node):
self.varname = varname
def __repr__(self) -> str:
- return "{}(childnode={!r}, varname={!r})".format(
- self.__class__.__name__,
- self.childnode,
- self.varname,
- )
+ return f"{self.__class__.__name__}(childnode={self.childnode!r}, varname={self.varname!r})"
class Repeat(Node):
@@ -265,7 +262,7 @@ def parse_regex(regex_tokens: list[str]) -> Node:
raise Exception(f"{t}-style repetition not yet supported")
elif t.startswith("(?"):
- raise Exception("%r not supported" % t)
+ raise Exception(f"{t!r} not supported")
elif t.isspace():
pass
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/validation.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/validation.py
index 8e56e05013..e6cfd74132 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/validation.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/regular_languages/validation.py
@@ -1,6 +1,7 @@
"""
Validator for a regular language.
"""
+
from __future__ import annotations
from prompt_toolkit.document import Document
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py
index 9a5d4022a0..4badc6cad0 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/ssh/server.py
@@ -1,6 +1,7 @@
"""
Utility for running a prompt_toolkit application in an asyncssh server.
"""
+
from __future__ import annotations
import asyncio
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/log.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/log.py
index 0fe843375c..476dffc677 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/log.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/log.py
@@ -1,6 +1,7 @@
"""
Python logger for the telnet server.
"""
+
from __future__ import annotations
import logging
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/protocol.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/protocol.py
index 4b90e9853a..58286e23e7 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/protocol.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/protocol.py
@@ -4,6 +4,7 @@ specification, but sufficient for a command line interface.)
Inspired by `Twisted.conch.telnet`.
"""
+
from __future__ import annotations
import struct
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py
index 9ebe66c62d..69e9a88adc 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/contrib/telnet/server.py
@@ -1,6 +1,7 @@
"""
Telnet server.
"""
+
from __future__ import annotations
import asyncio
@@ -99,7 +100,7 @@ class _ConnectionStdout:
if not self._closed:
self._connection.send(b"".join(self._buffer))
except OSError as e:
- logger.warning("Couldn't send data over socket: %s" % e)
+ logger.warning(f"Couldn't send data over socket: {e}")
self._buffer = []
@@ -416,7 +417,7 @@ class TelnetServer:
# Unhandled control-c propagated by a prompt.
logger.info("Unhandled KeyboardInterrupt in telnet application.")
except BaseException as e:
- print("Got %s" % type(e).__name__, e)
+ print(f"Got {type(e).__name__}", e)
import traceback
traceback.print_exc()
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/document.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/document.py
index 74f4c13f86..df5293e626 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/document.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/document.py
@@ -1,6 +1,7 @@
"""
The `Document` that implements all the text operations/querying.
"""
+
from __future__ import annotations
import bisect
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_generator.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_generator.py
index 5aee50a409..32e5f88247 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_generator.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/async_generator.py
@@ -1,6 +1,7 @@
"""
Implementation for async generators.
"""
+
from __future__ import annotations
from asyncio import get_running_loop
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py
index a4c0eee6bb..40016e87f6 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py
@@ -22,6 +22,7 @@ stuff to do. There are two ways to detect when to return:
asynchronous autocompletion. When the completion for instance is ready, we
also want prompt-toolkit to gain control again in order to display that.
"""
+
from __future__ import annotations
import asyncio
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/__init__.py
index 277f428ee9..556ed8846b 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/__init__.py
@@ -16,6 +16,7 @@ Filters can be chained using ``&`` and ``|`` operations, and inverted using the
filter = has_focus('default') & ~ has_selection
"""
+
from __future__ import annotations
from .app import *
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py
index aacb228416..b1b7c1beea 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py
@@ -1,6 +1,7 @@
"""
Filters that accept a `Application` as argument.
"""
+
from __future__ import annotations
from typing import TYPE_CHECKING, cast
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py
index afce6dc5a0..410749db47 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/base.py
@@ -30,7 +30,7 @@ class Filter(metaclass=ABCMeta):
"""
Chaining of filters using the & operator.
"""
- assert isinstance(other, Filter), "Expecting filter, got %r" % other
+ assert isinstance(other, Filter), f"Expecting filter, got {other!r}"
if isinstance(other, Always):
return self
@@ -48,7 +48,7 @@ class Filter(metaclass=ABCMeta):
"""
Chaining of filters using the | operator.
"""
- assert isinstance(other, Filter), "Expecting filter, got %r" % other
+ assert isinstance(other, Filter), f"Expecting filter, got {other!r}"
if isinstance(other, Always):
return other
@@ -193,7 +193,7 @@ class _Invert(Filter):
return not self.filter()
def __repr__(self) -> str:
- return "~%r" % self.filter
+ return f"~{self.filter!r}"
class Always(Filter):
@@ -207,6 +207,9 @@ class Always(Filter):
def __or__(self, other: Filter) -> Filter:
return self
+ def __and__(self, other: Filter) -> Filter:
+ return other
+
def __invert__(self) -> Never:
return Never()
@@ -222,6 +225,9 @@ class Never(Filter):
def __and__(self, other: Filter) -> Filter:
return self
+ def __or__(self, other: Filter) -> Filter:
+ return other
+
def __invert__(self) -> Always:
return Always()
@@ -248,7 +254,7 @@ class Condition(Filter):
return self.func()
def __repr__(self) -> str:
- return "Condition(%r)" % self.func
+ return f"Condition({self.func!r})"
# Often used as type annotation.
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/cli.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/cli.py
index c95080a927..902fbaae98 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/cli.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/cli.py
@@ -2,6 +2,7 @@
For backwards-compatibility. keep this file.
(Many people are going to have key bindings that rely on this file.)
"""
+
from __future__ import annotations
from .app import *
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/utils.py
index bac85bab62..20e00ee09e 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/utils.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/utils.py
@@ -29,7 +29,7 @@ def to_filter(bool_or_filter: FilterOrBool) -> Filter:
if isinstance(bool_or_filter, Filter):
return bool_or_filter
- raise TypeError("Expecting a bool or a Filter instance. Got %r" % bool_or_filter)
+ raise TypeError(f"Expecting a bool or a Filter instance. Got {bool_or_filter!r}")
def is_true(value: FilterOrBool) -> bool:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py
index db44ab9266..0590c81585 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/__init__.py
@@ -10,6 +10,7 @@ an :class:`.HTML` object, an :class:`.ANSI` object or a sequence of
`(style_string, text)` tuples. The :func:`.to_formatted_text` conversion
function takes any of these and turns all of them into such a tuple sequence.
"""
+
from __future__ import annotations
from .ansi import ANSI
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py
index 08ec0b322e..4761982ab3 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/ansi.py
@@ -210,10 +210,8 @@ class ANSI:
# True colors.
if n == 2 and len(attrs) >= 3:
try:
- color_str = "#{:02x}{:02x}{:02x}".format(
- attrs.pop(),
- attrs.pop(),
- attrs.pop(),
+ color_str = (
+ f"#{attrs.pop():02x}{attrs.pop():02x}{attrs.pop():02x}"
)
except IndexError:
pass
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py
index 92de353577..5fee1f862d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/base.py
@@ -38,8 +38,7 @@ if TYPE_CHECKING:
text.
"""
- def __pt_formatted_text__(self) -> StyleAndTextTuples:
- ...
+ def __pt_formatted_text__(self) -> StyleAndTextTuples: ...
AnyFormattedText = Union[
@@ -132,7 +131,7 @@ class FormattedText(StyleAndTextTuples):
return self
def __repr__(self) -> str:
- return "FormattedText(%s)" % super().__repr__()
+ return f"FormattedText({super().__repr__()})"
class Template:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py
index c8c37e0946..43228c3cda 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/formatted_text/utils.py
@@ -4,6 +4,7 @@ Utilities for manipulating formatted text.
When ``to_formatted_text`` has been called, we get a list of ``(style, text)``
tuples. This file contains functions for manipulating such a list.
"""
+
from __future__ import annotations
from typing import Iterable, cast
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/history.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/history.py
index 553918e58c..2d497a0209 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/history.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/history.py
@@ -7,6 +7,7 @@ NOTE: There is no `DynamicHistory`:
loading can be done asynchronously and making the history swappable would
probably break this.
"""
+
from __future__ import annotations
import datetime
@@ -14,7 +15,7 @@ import os
import threading
from abc import ABCMeta, abstractmethod
from asyncio import get_running_loop
-from typing import AsyncGenerator, Iterable, Sequence
+from typing import AsyncGenerator, Iterable, Sequence, Union
__all__ = [
"History",
@@ -254,12 +255,15 @@ class DummyHistory(History):
pass
+_StrOrBytesPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"]
+
+
class FileHistory(History):
"""
:class:`.History` class that stores all strings in a file.
"""
- def __init__(self, filename: str) -> None:
+ def __init__(self, filename: _StrOrBytesPath) -> None:
self.filename = filename
super().__init__()
@@ -297,6 +301,6 @@ class FileHistory(History):
def write(t: str) -> None:
f.write(t.encode("utf-8"))
- write("\n# %s\n" % datetime.datetime.now())
+ write(f"\n# {datetime.datetime.now()}\n")
for line in string.split("\n"):
- write("+%s\n" % line)
+ write(f"+{line}\n")
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/ansi_escape_sequences.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/ansi_escape_sequences.py
index 5648c6646a..1fba418b73 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/ansi_escape_sequences.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/ansi_escape_sequences.py
@@ -10,6 +10,7 @@ mostly Xterm compatible.
Some useful docs:
- Mintty: https://github.com/mintty/mintty/blob/master/wiki/Keycodes.md
"""
+
from __future__ import annotations
from ..keys import Keys
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
index fd1429df2e..3dcb994bd9 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
@@ -1,6 +1,7 @@
"""
Abstraction of CLI Input.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod, abstractproperty
@@ -116,7 +117,7 @@ class DummyInput(Input):
raise NotImplementedError
def typeahead_hash(self) -> str:
- return "dummy-%s" % id(self)
+ return f"dummy-{id(self)}"
def read_keys(self) -> list[KeyPress]:
return []
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/typeahead.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/typeahead.py
index a45e7cf50b..f8faa93289 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/typeahead.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/typeahead.py
@@ -31,6 +31,7 @@ To support type ahead, this module will store all the key strokes that were
read too early, so that they can be feed into to the next `prompt()` call or to
the next prompt_toolkit `Application`.
"""
+
from __future__ import annotations
from collections import defaultdict
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/vt100_parser.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/vt100_parser.py
index 99e2d99c58..73dbce3d83 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/vt100_parser.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/vt100_parser.py
@@ -1,6 +1,7 @@
"""
Parser for VT100 input stream.
"""
+
from __future__ import annotations
import re
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py
index 35e8948d22..322d7c0d72 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/win32.py
@@ -329,8 +329,8 @@ class ConsoleInputReader:
buffered_high_surrogate = None
for key in key_presses:
is_text = not isinstance(key.key, Keys)
- is_high_surrogate = is_text and "\uD800" <= key.key <= "\uDBFF"
- is_low_surrogate = is_text and "\uDC00" <= key.key <= "\uDFFF"
+ is_high_surrogate = is_text and "\ud800" <= key.key <= "\udbff"
+ is_low_surrogate = is_text and "\udc00" <= key.key <= "\udfff"
if buffered_high_surrogate:
if is_low_surrogate:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py
index 3d8a843d4a..b487f14ffe 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/auto_suggest.py
@@ -1,6 +1,7 @@
"""
Key bindings for auto suggestion (for fish-style auto suggestion).
"""
+
from __future__ import annotations
import re
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/basic.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/basic.py
index 084548d666..ad18df981c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/basic.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/basic.py
@@ -29,6 +29,16 @@ def if_no_repeat(event: E) -> bool:
return not event.is_repeat
+@Condition
+def has_text_before_cursor() -> bool:
+ return bool(get_app().current_buffer.text)
+
+
+@Condition
+def in_quoted_insert() -> bool:
+ return get_app().quoted_insert
+
+
def load_basic_bindings() -> KeyBindings:
key_bindings = KeyBindings()
insert_mode = vi_insert_mode | emacs_insert_mode
@@ -171,10 +181,6 @@ def load_basic_bindings() -> KeyBindings:
# CTRL keys.
- @Condition
- def has_text_before_cursor() -> bool:
- return bool(get_app().current_buffer.text)
-
handle("c-d", filter=has_text_before_cursor & insert_mode)(
get_by_name("delete-char")
)
@@ -240,10 +246,6 @@ def load_basic_bindings() -> KeyBindings:
event.current_buffer.insert_text(data)
- @Condition
- def in_quoted_insert() -> bool:
- return get_app().quoted_insert
-
@handle(Keys.Any, filter=in_quoted_insert, eager=True)
def _insert_text(event: E) -> None:
"""
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py
index 016821f492..8c5e005da8 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/completion.py
@@ -1,6 +1,7 @@
"""
Key binding handlers for displaying completions.
"""
+
from __future__ import annotations
import asyncio
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/emacs.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/emacs.py
index 80a66fd28a..207afba7ac 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/emacs.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/emacs.py
@@ -33,6 +33,16 @@ __all__ = [
E = KeyPressEvent
+@Condition
+def is_returnable() -> bool:
+ return get_app().current_buffer.is_returnable
+
+
+@Condition
+def is_arg() -> bool:
+ return get_app().key_processor.arg == "-"
+
+
def load_emacs_bindings() -> KeyBindingsBase:
"""
Some e-macs extensions.
@@ -134,7 +144,7 @@ def load_emacs_bindings() -> KeyBindingsBase:
if event._arg is None:
event.append_to_arg_count("-")
- @handle("-", filter=Condition(lambda: get_app().key_processor.arg == "-"))
+ @handle("-", filter=is_arg)
def _dash(event: E) -> None:
"""
When '-' is typed again, after exactly '-' has been given as an
@@ -142,10 +152,6 @@ def load_emacs_bindings() -> KeyBindingsBase:
"""
event.app.key_processor.arg = "-"
- @Condition
- def is_returnable() -> bool:
- return get_app().current_buffer.is_returnable
-
# Meta + Enter: always accept input.
handle("escape", "enter", filter=insert_mode & is_returnable)(
get_by_name("accept-line")
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py
index d8361169f9..8ea8dd03de 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/named_commands.py
@@ -3,6 +3,7 @@ Key bindings which are also known by GNU Readline by the given names.
See: http://www.delorie.com/gnu/docs/readline/rlman_13.html
"""
+
from __future__ import annotations
from typing import Callable, TypeVar, Union, cast
@@ -58,7 +59,7 @@ def get_by_name(name: str) -> Binding:
try:
return _readline_commands[name]
except KeyError as e:
- raise KeyError("Unknown Readline command: %r" % name) from e
+ raise KeyError(f"Unknown Readline command: {name!r}") from e
#
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/open_in_editor.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/open_in_editor.py
index d156424f20..26b8685b0a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/open_in_editor.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/open_in_editor.py
@@ -1,6 +1,7 @@
"""
Open in editor key bindings.
"""
+
from __future__ import annotations
from prompt_toolkit.filters import emacs_mode, has_selection, vi_navigation_mode
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/page_navigation.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/page_navigation.py
index 3918e14120..c490425fe2 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/page_navigation.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/page_navigation.py
@@ -2,6 +2,7 @@
Key bindings for extra page navigation: bindings for up/down scrolling through
long pages, like in Emacs or Vi.
"""
+
from __future__ import annotations
from prompt_toolkit.filters import buffer_has_focus, emacs_mode, vi_mode
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/scroll.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/scroll.py
index 83a4be1f8f..13e44ed4dc 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/scroll.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/scroll.py
@@ -5,6 +5,7 @@ This are separate bindings, because GNU readline doesn't have them, but
they are very useful for navigating through long multiline buffers, like in
Vi, Emacs, etc...
"""
+
from __future__ import annotations
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/search.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/search.py
index ba5e117ff6..a57c52e4f2 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/search.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/search.py
@@ -1,6 +1,7 @@
"""
Search related key bindings.
"""
+
from __future__ import annotations
from prompt_toolkit import search
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py
index 5cc74b4fb2..d68a31f29a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/bindings/vi.py
@@ -371,6 +371,35 @@ def create_operator_decorator(
return operator_decorator
+@Condition
+def is_returnable() -> bool:
+ return get_app().current_buffer.is_returnable
+
+
+@Condition
+def in_block_selection() -> bool:
+ buff = get_app().current_buffer
+ return bool(
+ buff.selection_state and buff.selection_state.type == SelectionType.BLOCK
+ )
+
+
+@Condition
+def digraph_symbol_1_given() -> bool:
+ return get_app().vi_state.digraph_symbol1 is not None
+
+
+@Condition
+def search_buffer_is_empty() -> bool:
+ "Returns True when the search buffer is empty."
+ return get_app().current_buffer.text == ""
+
+
+@Condition
+def tilde_operator() -> bool:
+ return get_app().vi_state.tilde_operator
+
+
def load_vi_bindings() -> KeyBindingsBase:
"""
Vi extensions.
@@ -410,7 +439,7 @@ def load_vi_bindings() -> KeyBindingsBase:
(("g", "~"), Always(), lambda string: string.swapcase()),
(
("~",),
- Condition(lambda: get_app().vi_state.tilde_operator),
+ tilde_operator,
lambda string: string.swapcase(),
),
]
@@ -528,10 +557,6 @@ def load_vi_bindings() -> KeyBindingsBase:
"""
event.current_buffer.cancel_completion()
- @Condition
- def is_returnable() -> bool:
- return get_app().current_buffer.is_returnable
-
# In navigation mode, pressing enter will always return the input.
handle("enter", filter=vi_navigation_mode & is_returnable)(
get_by_name("accept-line")
@@ -681,13 +706,6 @@ def load_vi_bindings() -> KeyBindingsBase:
)
)
- @Condition
- def in_block_selection() -> bool:
- buff = get_app().current_buffer
- return bool(
- buff.selection_state and buff.selection_state.type == SelectionType.BLOCK
- )
-
@handle("I", filter=in_block_selection & ~is_read_only)
def insert_in_block_selection(event: E, after: bool = False) -> None:
"""
@@ -2071,10 +2089,6 @@ def load_vi_bindings() -> KeyBindingsBase:
"""
event.app.vi_state.waiting_for_digraph = True
- @Condition
- def digraph_symbol_1_given() -> bool:
- return get_app().vi_state.digraph_symbol1 is not None
-
@handle(Keys.Any, filter=vi_digraph_mode & ~digraph_symbol_1_given)
def _digraph1(event: E) -> None:
"""
@@ -2180,11 +2194,6 @@ def load_vi_search_bindings() -> KeyBindingsBase:
handle = key_bindings.add
from . import search
- @Condition
- def search_buffer_is_empty() -> bool:
- "Returns True when the search buffer is empty."
- return get_app().current_buffer.text == ""
-
# Vi-style forward search.
handle(
"/",
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/defaults.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/defaults.py
index 166da8d4ac..6c26571160 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/defaults.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/defaults.py
@@ -4,6 +4,7 @@ Default key bindings.::
key_bindings = load_key_bindings()
app = Application(key_bindings=key_bindings)
"""
+
from __future__ import annotations
from prompt_toolkit.filters import buffer_has_focus
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/digraphs.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/digraphs.py
index 1e8a43266b..f0152dc4cb 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/digraphs.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/digraphs.py
@@ -6,6 +6,7 @@ pressing Control-K followed by to normal characters.
Taken from Neovim and translated to Python:
https://raw.githubusercontent.com/neovim/neovim/master/src/nvim/digraph.c
"""
+
from __future__ import annotations
__all__ = [
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_bindings.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_bindings.py
index 62530f2b77..854da8012b 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_bindings.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_bindings.py
@@ -34,6 +34,7 @@ been assigned, through the `key_binding` decorator.::
# Later, add it to the key bindings.
kb.add(Keys.A, my_key_binding)
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod, abstractproperty
@@ -140,10 +141,8 @@ class Binding:
event.app.invalidate()
def __repr__(self) -> str:
- return "{}(keys={!r}, handler={!r})".format(
- self.__class__.__name__,
- self.keys,
- self.handler,
+ return (
+ f"{self.__class__.__name__}(keys={self.keys!r}, handler={self.handler!r})"
)
@@ -226,9 +225,9 @@ class KeyBindings(KeyBindingsBase):
def __init__(self) -> None:
self._bindings: list[Binding] = []
- self._get_bindings_for_keys_cache: SimpleCache[
- KeysTuple, list[Binding]
- ] = SimpleCache(maxsize=10000)
+ self._get_bindings_for_keys_cache: SimpleCache[KeysTuple, list[Binding]] = (
+ SimpleCache(maxsize=10000)
+ )
self._get_bindings_starting_with_keys_cache: SimpleCache[
KeysTuple, list[Binding]
] = SimpleCache(maxsize=1000)
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py
index 4c4f0d155d..e2070a14f0 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/key_binding/key_processor.py
@@ -5,6 +5,7 @@ the input in the :class:`~prompt_toolkit.inputstream.InputStream` instance.
The `KeyProcessor` will according to the implemented keybindings call the
correct callbacks when new key presses are feed through `feed`.
"""
+
from __future__ import annotations
import weakref
@@ -450,11 +451,7 @@ class KeyPressEvent:
self._app = get_app()
def __repr__(self) -> str:
- return "KeyPressEvent(arg={!r}, key_sequence={!r}, is_repeat={!r})".format(
- self.arg,
- self.key_sequence,
- self.is_repeat,
- )
+ return f"KeyPressEvent(arg={self.arg!r}, key_sequence={self.key_sequence!r}, is_repeat={self.is_repeat!r})"
@property
def data(self) -> str:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/__init__.py
index c5fce461a0..7cd0c7725c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/__init__.py
@@ -44,6 +44,7 @@ And one prepared menu:
- CompletionsMenu
"""
+
from __future__ import annotations
from .containers import (
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py
index 100d4aaebc..99b453477c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py
@@ -2,6 +2,7 @@
Container for the layout.
(Containers can contain other containers or user interface controls.)
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
@@ -156,8 +157,7 @@ if TYPE_CHECKING:
Any object that implements ``__pt_container__`` represents a container.
"""
- def __pt_container__(self) -> AnyContainer:
- ...
+ def __pt_container__(self) -> AnyContainer: ...
AnyContainer = Union[Container, "MagicContainer"]
@@ -296,9 +296,9 @@ class HSplit(_Split):
self.align = align
- self._children_cache: SimpleCache[
- tuple[Container, ...], list[Container]
- ] = SimpleCache(maxsize=1)
+ self._children_cache: SimpleCache[tuple[Container, ...], list[Container]] = (
+ SimpleCache(maxsize=1)
+ )
self._remaining_space_window = Window() # Dummy window.
def preferred_width(self, max_available_width: int) -> Dimension:
@@ -533,9 +533,9 @@ class VSplit(_Split):
self.align = align
- self._children_cache: SimpleCache[
- tuple[Container, ...], list[Container]
- ] = SimpleCache(maxsize=1)
+ self._children_cache: SimpleCache[tuple[Container, ...], list[Container]] = (
+ SimpleCache(maxsize=1)
+ )
self._remaining_space_window = Window() # Dummy window.
def preferred_width(self, max_available_width: int) -> Dimension:
@@ -1093,7 +1093,7 @@ class Float:
return self.height
def __repr__(self) -> str:
- return "Float(content=%r)" % self.content
+ return f"Float(content={self.content!r})"
class WindowRenderInfo:
@@ -1352,12 +1352,7 @@ class ScrollOffsets:
return to_int(self._right)
def __repr__(self) -> str:
- return "ScrollOffsets(top={!r}, bottom={!r}, left={!r}, right={!r})".format(
- self._top,
- self._bottom,
- self._left,
- self._right,
- )
+ return f"ScrollOffsets(top={self._top!r}, bottom={self._bottom!r}, left={self._left!r}, right={self._right!r})"
class ColorColumn:
@@ -1504,9 +1499,9 @@ class Window(Container):
self.z_index = z_index
# Cache for the screens generated by the margin.
- self._ui_content_cache: SimpleCache[
- tuple[int, int, int], UIContent
- ] = SimpleCache(maxsize=8)
+ self._ui_content_cache: SimpleCache[tuple[int, int, int], UIContent] = (
+ SimpleCache(maxsize=8)
+ )
self._margin_width_cache: SimpleCache[tuple[Margin, int], int] = SimpleCache(
maxsize=1
)
@@ -1514,7 +1509,7 @@ class Window(Container):
self.reset()
def __repr__(self) -> str:
- return "Window(content=%r)" % self.content
+ return f"Window(content={self.content!r})"
def reset(self) -> None:
self.content.reset()
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py
index c30c0effa8..222e471c57 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py
@@ -1,6 +1,7 @@
"""
User interface Controls for the layout.
"""
+
from __future__ import annotations
import time
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py
index c1f05f9439..2e6f5dd4eb 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dimension.py
@@ -2,6 +2,7 @@
Layout dimensions are used to give the minimum, maximum and preferred
dimensions for containers and controls.
"""
+
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Callable, Union
@@ -105,15 +106,15 @@ class Dimension:
def __repr__(self) -> str:
fields = []
if self.min_specified:
- fields.append("min=%r" % self.min)
+ fields.append(f"min={self.min!r}")
if self.max_specified:
- fields.append("max=%r" % self.max)
+ fields.append(f"max={self.max!r}")
if self.preferred_specified:
- fields.append("preferred=%r" % self.preferred)
+ fields.append(f"preferred={self.preferred!r}")
if self.weight_specified:
- fields.append("weight=%r" % self.weight)
+ fields.append(f"weight={self.weight!r}")
- return "Dimension(%s)" % ", ".join(fields)
+ return "Dimension({})".format(", ".join(fields))
def sum_layout_dimensions(dimensions: list[Dimension]) -> Dimension:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dummy.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dummy.py
index 139f311579..1ee3e6c9bd 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dummy.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/dummy.py
@@ -2,6 +2,7 @@
Dummy layout. Used when somebody creates an `Application` without specifying a
`Layout`.
"""
+
from __future__ import annotations
from prompt_toolkit.formatted_text import HTML
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py
index a5e7a80e75..f9b7110925 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/layout.py
@@ -1,6 +1,7 @@
"""
Wrapper for the layout.
"""
+
from __future__ import annotations
from typing import Generator, Iterable, Union
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/margins.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/margins.py
index cc9dd964b4..737a74d29b 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/margins.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/margins.py
@@ -1,6 +1,7 @@
"""
Margin implementations for a :class:`~prompt_toolkit.layout.containers.Window`.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
@@ -83,7 +84,7 @@ class NumberedMargin(Margin):
def get_width(self, get_ui_content: Callable[[], UIContent]) -> int:
line_count = get_ui_content().line_count
- return max(3, len("%s" % line_count) + 1)
+ return max(3, len(f"{line_count}") + 1)
def create_margin(
self, window_render_info: WindowRenderInfo, width: int, height: int
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py
index 2c2ccb6436..612e8ab6a3 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py
@@ -212,10 +212,7 @@ def _get_menu_item_fragments(
width.
"""
if is_current_completion:
- style_str = "class:completion-menu.completion.current {} {}".format(
- completion.style,
- completion.selected_style,
- )
+ style_str = f"class:completion-menu.completion.current {completion.style} {completion.selected_style}"
else:
style_str = "class:completion-menu.completion " + completion.style
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py
index 56a4eddd9d..52deac1456 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/mouse_handlers.py
@@ -34,9 +34,9 @@ class MouseHandlers:
# over the mouse handlers of the visible region in the scrollable pane.
# Map y (row) to x (column) to handlers.
- self.mouse_handlers: defaultdict[
- int, defaultdict[int, MouseHandler]
- ] = defaultdict(lambda: defaultdict(lambda: dummy_callback))
+ self.mouse_handlers: defaultdict[int, defaultdict[int, MouseHandler]] = (
+ defaultdict(lambda: defaultdict(lambda: dummy_callback))
+ )
def set_mouse_handler_for_range(
self,
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
index b7376115e4..b10ecf7184 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py
@@ -5,6 +5,7 @@ from a buffer before the BufferControl will render it to the screen.
They can insert fragments before or after, or highlight fragments by replacing the
fragment types.
"""
+
from __future__ import annotations
import re
@@ -343,9 +344,9 @@ class HighlightMatchingBracketProcessor(Processor):
self.chars = chars
self.max_cursor_distance = max_cursor_distance
- self._positions_cache: SimpleCache[
- Hashable, list[tuple[int, int]]
- ] = SimpleCache(maxsize=8)
+ self._positions_cache: SimpleCache[Hashable, list[tuple[int, int]]] = (
+ SimpleCache(maxsize=8)
+ )
def _get_positions_to_highlight(self, document: Document) -> list[tuple[int, int]]:
"""
@@ -924,11 +925,7 @@ class ConditionalProcessor(Processor):
return Transformation(transformation_input.fragments)
def __repr__(self) -> str:
- return "{}(processor={!r}, filter={!r})".format(
- self.__class__.__name__,
- self.processor,
- self.filter,
- )
+ return f"{self.__class__.__name__}(processor={self.processor!r}, filter={self.filter!r})"
class DynamicProcessor(Processor):
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py
index 49aebbd626..0f19f52a8d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/screen.py
@@ -320,10 +320,4 @@ class WritePosition:
self.height = height
def __repr__(self) -> str:
- return "{}(x={!r}, y={!r}, width={!r}, height={!r})".format(
- self.__class__.__name__,
- self.xpos,
- self.ypos,
- self.width,
- self.height,
- )
+ return f"{self.__class__.__name__}(x={self.xpos!r}, y={self.ypos!r}, width={self.width!r}, height={self.height!r})"
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/utils.py
index 0f78f3713c..373fe52a5a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/utils.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/utils.py
@@ -36,12 +36,10 @@ class _ExplodedList(List[_T]):
# TODO: When creating a copy() or [:], return also an _ExplodedList.
@overload
- def __setitem__(self, index: SupportsIndex, value: _T) -> None:
- ...
+ def __setitem__(self, index: SupportsIndex, value: _T) -> None: ...
@overload
- def __setitem__(self, index: slice, value: Iterable[_T]) -> None:
- ...
+ def __setitem__(self, index: slice, value: Iterable[_T]) -> None: ...
def __setitem__(
self, index: SupportsIndex | slice, value: _T | Iterable[_T]
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/__init__.py
index 9bdc599847..8f72d07ff2 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/__init__.py
@@ -2,6 +2,7 @@
Lexer interface and implementations.
Used for syntax highlighting.
"""
+
from __future__ import annotations
from .base import DynamicLexer, Lexer, SimpleLexer
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/base.py
index 3f65f8e7c1..c61e2b9d32 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/base.py
@@ -1,6 +1,7 @@
"""
Base classes for prompt_toolkit lexers.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py
index 4721d730c8..d5a39c4993 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py
@@ -4,6 +4,7 @@ Adaptor classes for using Pygments lexers within prompt_toolkit.
This includes syntax synchronization code, so that we don't have to start
lexing at the beginning of a document, when displaying a very large text.
"""
+
from __future__ import annotations
import re
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/log.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/log.py
index adb5172afd..285357927a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/log.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/log.py
@@ -1,6 +1,7 @@
"""
Logging configuration.
"""
+
from __future__ import annotations
import logging
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/mouse_events.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/mouse_events.py
index 743773b506..f244f8eac4 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/mouse_events.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/mouse_events.py
@@ -15,6 +15,7 @@ through the `Window` class where the coordinates are translated from absolute
coordinates to coordinates relative to the user control, and there
`UIControl.mouse_handler` is called.
"""
+
from __future__ import annotations
from enum import Enum
@@ -81,9 +82,4 @@ class MouseEvent:
self.modifiers = modifiers
def __repr__(self) -> str:
- return "MouseEvent({!r},{!r},{!r},{!r})".format(
- self.position,
- self.event_type,
- self.button,
- self.modifiers,
- )
+ return f"MouseEvent({self.position!r},{self.event_type!r},{self.button!r},{self.modifiers!r})"
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py
index 3c38cec86e..6ba09fdd08 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py
@@ -1,6 +1,7 @@
"""
Interface for an output.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py
index 142deab077..069636b8c3 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py
@@ -6,6 +6,7 @@ A lot of thanks, regarding outputting of colors, goes to the Pygments project:
everything has been highly optimized.)
http://pygments.org/
"""
+
from __future__ import annotations
import io
@@ -521,7 +522,7 @@ class Vt100_Output(Output):
"eterm-color",
): # Not supported by the Linux console.
self.write_raw(
- "\x1b]2;%s\x07" % title.replace("\x1b", "").replace("\x07", "")
+ "\x1b]2;{}\x07".format(title.replace("\x1b", "").replace("\x07", ""))
)
def clear_title(self) -> None:
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py
index edeca0968d..83ccea43fc 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/win32.py
@@ -73,11 +73,11 @@ class NoConsoleScreenBufferError(Exception):
if xterm:
message = (
- "Found %s, while expecting a Windows console. "
+ "Found {}, while expecting a Windows console. "
'Maybe try to run this program using "winpty" '
"or run it in cmd.exe instead. Or otherwise, "
"in case of Cygwin, use the Python executable "
- "that is compiled for Cygwin." % os.environ["TERM"]
+ "that is compiled for Cygwin.".format(os.environ["TERM"])
)
else:
message = "No Windows console found. Are you running cmd.exe?"
@@ -163,13 +163,13 @@ class Win32Output(Output):
self.flush()
if _DEBUG_RENDER_OUTPUT:
- self.LOG.write(("%r" % func.__name__).encode("utf-8") + b"\n")
+ self.LOG.write((f"{func.__name__!r}").encode() + b"\n")
self.LOG.write(
- b" " + ", ".join(["%r" % i for i in a]).encode("utf-8") + b"\n"
+ b" " + ", ".join([f"{i!r}" for i in a]).encode("utf-8") + b"\n"
)
self.LOG.write(
b" "
- + ", ".join(["%r" % type(i) for i in a]).encode("utf-8")
+ + ", ".join([f"{type(i)!r}" for i in a]).encode("utf-8")
+ b"\n"
)
self.LOG.flush()
@@ -370,7 +370,7 @@ class Win32Output(Output):
data = "".join(self._buffer)
if _DEBUG_RENDER_OUTPUT:
- self.LOG.write(("%r" % data).encode("utf-8") + b"\n")
+ self.LOG.write((f"{data!r}").encode() + b"\n")
self.LOG.flush()
# Print characters one by one. This appears to be the best solution
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py
index 528bec7ffe..4958e9d2e4 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py
@@ -17,6 +17,7 @@ Usage::
Multiple applications can run in the body of the context manager, one after the
other.
"""
+
from __future__ import annotations
import asyncio
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py
index 5ad1dd68d0..3f92303a81 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py
@@ -2,6 +2,7 @@
Renders the command line on the console.
(Redraws parts of the input line that were changed.)
"""
+
from __future__ import annotations
from asyncio import FIRST_COMPLETED, Future, ensure_future, sleep, wait
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py
index fd90a04e90..d1cf7acbac 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/search.py
@@ -5,6 +5,7 @@ For the key bindings implementation with attached filters, check
`prompt_toolkit.key_binding.bindings.search`. (Use these for new key bindings
instead of calling these function directly.)
"""
+
from __future__ import annotations
from enum import Enum
@@ -59,12 +60,7 @@ class SearchState:
self.ignore_case = to_filter(ignore_case)
def __repr__(self) -> str:
- return "{}({!r}, direction={!r}, ignore_case={!r})".format(
- self.__class__.__name__,
- self.text,
- self.direction,
- self.ignore_case,
- )
+ return f"{self.__class__.__name__}({self.text!r}, direction={self.direction!r}, ignore_case={self.ignore_case!r})"
def __invert__(self) -> SearchState:
"""
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/selection.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/selection.py
index 2158fa92a2..ff88535b0f 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/selection.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/selection.py
@@ -1,6 +1,7 @@
"""
Data structures for the selection.
"""
+
from __future__ import annotations
from enum import Enum
@@ -54,8 +55,4 @@ class SelectionState:
self.shift_mode = True
def __repr__(self) -> str:
- return "{}(original_cursor_position={!r}, type={!r})".format(
- self.__class__.__name__,
- self.original_cursor_position,
- self.type,
- )
+ return f"{self.__class__.__name__}(original_cursor_position={self.original_cursor_position!r}, type={self.type!r})"
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py
index 21aa1bece5..a7c2a527d8 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/base.py
@@ -7,6 +7,7 @@ Progress bar implementation on top of prompt_toolkit.
for item in pb(data):
...
"""
+
from __future__ import annotations
import contextvars
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
index dd0339c3ad..202949ca07 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/progress_bar/formatters.py
@@ -2,6 +2,7 @@
Formatter classes for the progress bar.
Each progress bar consists of a list of these formatters.
"""
+
from __future__ import annotations
import datetime
@@ -130,7 +131,7 @@ class Percentage(Formatter):
Display the progress as a percentage.
"""
- template = "<percentage>{percentage:>5}%</percentage>"
+ template = HTML("<percentage>{percentage:>5}%</percentage>")
def format(
self,
@@ -138,7 +139,7 @@ class Percentage(Formatter):
progress: ProgressBarCounter[object],
width: int,
) -> AnyFormattedText:
- return HTML(self.template).format(percentage=round(progress.percentage, 1))
+ return self.template.format(percentage=round(progress.percentage, 1))
def get_width(self, progress_bar: ProgressBar) -> AnyDimension:
return D.exact(6)
@@ -149,7 +150,9 @@ class Bar(Formatter):
Display the progress bar itself.
"""
- template = "<bar>{start}<bar-a>{bar_a}</bar-a><bar-b>{bar_b}</bar-b><bar-c>{bar_c}</bar-c>{end}</bar>"
+ template = HTML(
+ "<bar>{start}<bar-a>{bar_a}</bar-a><bar-b>{bar_b}</bar-b><bar-c>{bar_c}</bar-c>{end}</bar>"
+ )
def __init__(
self,
@@ -202,7 +205,7 @@ class Bar(Formatter):
bar_b = sym_b
bar_c = sym_c * (width - pb_a)
- return HTML(self.template).format(
+ return self.template.format(
start=self.start, end=self.end, bar_a=bar_a, bar_b=bar_b, bar_c=bar_c
)
@@ -215,7 +218,7 @@ class Progress(Formatter):
Display the progress as text. E.g. "8/20"
"""
- template = "<current>{current:>3}</current>/<total>{total:>3}</total>"
+ template = HTML("<current>{current:>3}</current>/<total>{total:>3}</total>")
def format(
self,
@@ -223,7 +226,7 @@ class Progress(Formatter):
progress: ProgressBarCounter[object],
width: int,
) -> AnyFormattedText:
- return HTML(self.template).format(
+ return self.template.format(
current=progress.items_completed, total=progress.total or "?"
)
@@ -250,6 +253,8 @@ class TimeElapsed(Formatter):
Display the elapsed time.
"""
+ template = HTML("<time-elapsed>{time_elapsed}</time-elapsed>")
+
def format(
self,
progress_bar: ProgressBar,
@@ -257,9 +262,7 @@ class TimeElapsed(Formatter):
width: int,
) -> AnyFormattedText:
text = _format_timedelta(progress.time_elapsed).rjust(width)
- return HTML("<time-elapsed>{time_elapsed}</time-elapsed>").format(
- time_elapsed=text
- )
+ return self.template.format(time_elapsed=text)
def get_width(self, progress_bar: ProgressBar) -> AnyDimension:
all_values = [
@@ -275,7 +278,7 @@ class TimeLeft(Formatter):
Display the time left.
"""
- template = "<time-left>{time_left}</time-left>"
+ template = HTML("<time-left>{time_left}</time-left>")
unknown = "?:??:??"
def format(
@@ -290,7 +293,7 @@ class TimeLeft(Formatter):
else:
formatted_time_left = self.unknown
- return HTML(self.template).format(time_left=formatted_time_left.rjust(width))
+ return self.template.format(time_left=formatted_time_left.rjust(width))
def get_width(self, progress_bar: ProgressBar) -> AnyDimension:
all_values = [
@@ -307,7 +310,7 @@ class IterationsPerSecond(Formatter):
Display the iterations per second.
"""
- template = (
+ template = HTML(
"<iterations-per-second>{iterations_per_second:.2f}</iterations-per-second>"
)
@@ -318,7 +321,7 @@ class IterationsPerSecond(Formatter):
width: int,
) -> AnyFormattedText:
value = progress.items_completed / progress.time_elapsed.total_seconds()
- return HTML(self.template.format(iterations_per_second=value))
+ return self.template.format(iterations_per_second=value)
def get_width(self, progress_bar: ProgressBar) -> AnyDimension:
all_values = [
@@ -335,6 +338,7 @@ class SpinningWheel(Formatter):
Display a spinning wheel.
"""
+ template = HTML("<spinning-wheel>{0}</spinning-wheel>")
characters = r"/-\|"
def format(
@@ -344,9 +348,7 @@ class SpinningWheel(Formatter):
width: int,
) -> AnyFormattedText:
index = int(time.time() * 3) % len(self.characters)
- return HTML("<spinning-wheel>{0}</spinning-wheel>").format(
- self.characters[index]
- )
+ return self.template.format(self.characters[index])
def get_width(self, progress_bar: ProgressBar) -> AnyDimension:
return D.exact(1)
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
index 7274b5f03e..115d890075 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/shortcuts/prompt.py
@@ -24,6 +24,7 @@ Example::
s = PromptSession()
result = s.prompt('Say something: ')
"""
+
from __future__ import annotations
from asyncio import get_running_loop
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/__init__.py
index 23f61bb0f6..39e97cac8e 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/__init__.py
@@ -1,6 +1,7 @@
"""
Styling for prompt_toolkit applications.
"""
+
from __future__ import annotations
from .base import (
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/base.py
index b50f3b0ea4..06572210a9 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/base.py
@@ -1,6 +1,7 @@
"""
The base classes for the styling.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod, abstractproperty
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/defaults.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/defaults.py
index 75b8dd21a6..2faba94378 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/defaults.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/defaults.py
@@ -1,6 +1,7 @@
"""
The default styling.
"""
+
from __future__ import annotations
from prompt_toolkit.cache import memoized
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/named_colors.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/named_colors.py
index 0395c8bc59..b6290a4e8f 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/named_colors.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/named_colors.py
@@ -2,6 +2,7 @@
All modern web browsers support these 140 color names.
Taken from: https://www.w3schools.com/colors/colors_names.asp
"""
+
from __future__ import annotations
__all__ = [
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/pygments.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/pygments.py
index 3e101f1d36..c0f603108f 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/pygments.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/pygments.py
@@ -6,6 +6,7 @@ Usage::
from pygments.styles.tango import TangoStyle
style = style_from_pygments_cls(pygments_style_cls=TangoStyle)
"""
+
from __future__ import annotations
from typing import TYPE_CHECKING
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style.py
index 1abee0f53b..fc8b31bd0a 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style.py
@@ -1,6 +1,7 @@
"""
Tool for creating styles from a dictionary.
"""
+
from __future__ import annotations
import itertools
@@ -72,7 +73,7 @@ def parse_color(text: str) -> str:
elif text in ("", "default"):
return text
- raise ValueError("Wrong color format %r" % text)
+ raise ValueError(f"Wrong color format {text!r}")
# Attributes, when they are not filled in by a style. None means that we take
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style_transformation.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style_transformation.py
index fbb5a639ab..e8d5b0a89f 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style_transformation.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/styles/style_transformation.py
@@ -9,6 +9,7 @@ When the UI is rendered, these transformations can be applied right after the
style strings are turned into `Attrs` objects that represent the actual
formatting.
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/token.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/token.py
index a2c80e54c5..e97893de67 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/token.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/token.py
@@ -1,5 +1,4 @@
-"""
-"""
+""" """
from __future__ import annotations
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/validation.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/validation.py
index 127445e86e..2b35d1fcc9 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/validation.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/validation.py
@@ -2,6 +2,7 @@
Input validation for a `Buffer`.
(Validators will be called before accepting input.)
"""
+
from __future__ import annotations
from abc import ABCMeta, abstractmethod
@@ -36,11 +37,7 @@ class ValidationError(Exception):
self.message = message
def __repr__(self) -> str:
- return "{}(cursor_position={!r}, message={!r})".format(
- self.__class__.__name__,
- self.cursor_position,
- self.message,
- )
+ return f"{self.__class__.__name__}(cursor_position={self.cursor_position!r}, message={self.message!r})"
class Validator(metaclass=ABCMeta):
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/__init__.py
index 9d1d4e3dee..53cc3e1394 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/__init__.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/__init__.py
@@ -6,6 +6,7 @@ module.
Most of these widgets implement the ``__pt_container__`` method, which makes it
possible to embed these in the layout like any other container.
"""
+
from __future__ import annotations
from .base import (
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py
index f36a545755..709b7a9499 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/base.py
@@ -12,6 +12,7 @@ container object.
guarantees are made yet). The public API in
`prompt_toolkit.shortcuts.dialogs` on the other hand is considered stable.
"""
+
from __future__ import annotations
from functools import partial
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/dialogs.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/dialogs.py
index c47c15b4f9..5f5f17026d 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/dialogs.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/dialogs.py
@@ -1,6 +1,7 @@
"""
Collection of reusable components for building full screen applications.
"""
+
from __future__ import annotations
from typing import Sequence
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/toolbars.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/toolbars.py
index deddf15423..c5deffc58c 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/toolbars.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/widgets/toolbars.py
@@ -352,11 +352,7 @@ class ValidationToolbar:
)
if show_position:
- text = "{} (line={} column={})".format(
- buff.validation_error.message,
- row + 1,
- column + 1,
- )
+ text = f"{buff.validation_error.message} (line={row + 1} column={column + 1})"
else:
text = buff.validation_error.message