diff options
author | AlexSm <alex@ydb.tech> | 2023-12-27 23:31:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 23:31:58 +0100 |
commit | d67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch) | |
tree | 8674f2f1570877cb653e7ddcff37ba00288de15a /contrib/python/prompt-toolkit | |
parent | 1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff) | |
download | ydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz |
Import libs 4 (#758)
Diffstat (limited to 'contrib/python/prompt-toolkit')
26 files changed, 108 insertions, 56 deletions
diff --git a/contrib/python/prompt-toolkit/py3/.dist-info/METADATA b/contrib/python/prompt-toolkit/py3/.dist-info/METADATA index ab2db30bbf..13de29c342 100644 --- a/contrib/python/prompt-toolkit/py3/.dist-info/METADATA +++ b/contrib/python/prompt-toolkit/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: prompt-toolkit -Version: 3.0.41 +Version: 3.0.43 Summary: Library for building powerful interactive command lines in Python Home-page: https://github.com/prompt-toolkit/python-prompt-toolkit Author: Jonathan Slenders diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py index 2d408152fe..82324cb815 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/__init__.py @@ -27,7 +27,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.41" +__version__ = "3.0.43" 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 726fc0a067..d4637811ba 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/application.py @@ -807,16 +807,19 @@ class Application(Generic[_AppResult]): @contextmanager def set_handle_sigint(loop: AbstractEventLoop) -> Iterator[None]: if handle_sigint: - loop.add_signal_handler( - signal.SIGINT, - lambda *_: loop.call_soon_threadsafe( - self.key_processor.send_sigint - ), - ) - try: - yield - finally: - loop.remove_signal_handler(signal.SIGINT) + with _restore_sigint_from_ctypes(): + # save sigint handlers (python and os level) + # See: https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1576 + loop.add_signal_handler( + signal.SIGINT, + lambda *_: loop.call_soon_threadsafe( + self.key_processor.send_sigint + ), + ) + try: + yield + finally: + loop.remove_signal_handler(signal.SIGINT) else: yield @@ -960,7 +963,8 @@ class Application(Generic[_AppResult]): def _called_from_ipython() -> bool: try: return ( - "IPython/terminal/interactiveshell.py" + sys.modules["IPython"].version_info < (8, 18, 0, "") + and "IPython/terminal/interactiveshell.py" in sys._getframe(3).f_code.co_filename ) except BaseException: @@ -1545,7 +1549,7 @@ async def _do_wait_for_enter(wait_text: AnyFormattedText) -> None: @contextmanager def attach_winch_signal_handler( - handler: Callable[[], None] + handler: Callable[[], None], ) -> Generator[None, None, None]: """ Attach the given callback as a WINCH signal handler within the context @@ -1586,3 +1590,36 @@ def attach_winch_signal_handler( previous_winch_handler._callback, *previous_winch_handler._args, ) + + +@contextmanager +def _restore_sigint_from_ctypes() -> Generator[None, None, None]: + # The following functions are part of the stable ABI since python 3.2 + # See: https://docs.python.org/3/c-api/sys.html#c.PyOS_getsig + # Inline import: these are not available on Pypy. + try: + from ctypes import c_int, c_void_p, pythonapi + except ImportError: + # Any of the above imports don't exist? Don't do anything here. + yield + return + + # PyOS_sighandler_t PyOS_getsig(int i) + pythonapi.PyOS_getsig.restype = c_void_p + pythonapi.PyOS_getsig.argtypes = (c_int,) + + # PyOS_sighandler_t PyOS_setsig(int i, PyOS_sighandler_t h) + pythonapi.PyOS_setsig.restype = c_void_p + pythonapi.PyOS_setsig.argtypes = ( + c_int, + c_void_p, + ) + + sigint = signal.getsignal(signal.SIGINT) + sigint_os = pythonapi.PyOS_getsig(signal.SIGINT) + + try: + yield + finally: + signal.signal(signal.SIGINT, sigint) + pythonapi.PyOS_setsig(signal.SIGINT, sigint_os) diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py index 7dbc7a6fb3..100ca78d7b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/buffer.py @@ -15,7 +15,7 @@ import tempfile from collections import deque from enum import Enum from functools import wraps -from typing import Any, Awaitable, Callable, Coroutine, Iterable, TypeVar, cast +from typing import Any, Callable, Coroutine, Iterable, TypeVar, cast from .application.current import get_app from .application.run_in_terminal import run_in_terminal @@ -1891,7 +1891,7 @@ class Buffer: self.reset() -_T = TypeVar("_T", bound=Callable[..., Awaitable[None]]) +_T = TypeVar("_T", bound=Callable[..., Coroutine[Any, Any, None]]) def _only_one_at_a_time(coroutine: _T) -> _T: 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 1743af4e74..c947fd5337 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 @@ -30,7 +30,7 @@ What can we do with this grammar? --------------------------------- - Syntax highlighting: We could use this for instance to give file names - different colour. + different color. - Parse the result: .. We can extract the file names and commands by using a regular expression with named groups. - Input validation: .. Don't accept anything that does not match this grammar. 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 5f9b5f6b7c..9a5d4022a0 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 @@ -6,7 +6,7 @@ from __future__ import annotations import asyncio import traceback from asyncio import get_running_loop -from typing import Any, Awaitable, Callable, TextIO, cast +from typing import Any, Callable, Coroutine, TextIO, cast import asyncssh @@ -21,7 +21,7 @@ __all__ = ["PromptToolkitSSHSession", "PromptToolkitSSHServer"] class PromptToolkitSSHSession(asyncssh.SSHServerSession): # type: ignore def __init__( self, - interact: Callable[[PromptToolkitSSHSession], Awaitable[None]], + interact: Callable[[PromptToolkitSSHSession], Coroutine[Any, Any, None]], *, enable_cpr: bool, ) -> None: @@ -162,7 +162,7 @@ class PromptToolkitSSHServer(asyncssh.SSHServer): def __init__( self, - interact: Callable[[PromptToolkitSSHSession], Awaitable[None]], + interact: Callable[[PromptToolkitSSHSession], Coroutine[Any, Any, None]], *, enable_cpr: bool = True, ) -> None: 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 81c19f6c88..9ebe66c62d 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 @@ -7,7 +7,7 @@ import asyncio import contextvars import socket from asyncio import get_running_loop -from typing import Awaitable, Callable, TextIO, cast +from typing import Any, Callable, Coroutine, TextIO, cast from prompt_toolkit.application.current import create_app_session, get_app from prompt_toolkit.application.run_in_terminal import run_in_terminal @@ -124,7 +124,7 @@ class TelnetConnection: self, conn: socket.socket, addr: tuple[str, int], - interact: Callable[[TelnetConnection], Awaitable[None]], + interact: Callable[[TelnetConnection], Coroutine[Any, Any, None]], server: TelnetServer, encoding: str, style: BaseStyle | None, @@ -283,7 +283,9 @@ class TelnetServer: self, host: str = "127.0.0.1", port: int = 23, - interact: Callable[[TelnetConnection], Awaitable[None]] = _dummy_interact, + interact: Callable[ + [TelnetConnection], Coroutine[Any, Any, None] + ] = _dummy_interact, encoding: str = "utf-8", style: BaseStyle | None = None, enable_cpr: bool = True, 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 5731573f52..a4c0eee6bb 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/eventloop/inputhook.py @@ -66,7 +66,7 @@ InputHook: TypeAlias = Callable[[InputHookContext], None] def new_eventloop_with_inputhook( - inputhook: Callable[[InputHookContext], None] + inputhook: Callable[[InputHookContext], None], ) -> AbstractEventLoop: """ Create a new event loop with the given inputhook. @@ -77,7 +77,7 @@ def new_eventloop_with_inputhook( def set_eventloop_with_inputhook( - inputhook: Callable[[InputHookContext], None] + inputhook: Callable[[InputHookContext], None], ) -> AbstractEventLoop: """ Create a new event loop with the given inputhook, and activate it. 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 303a078c4e..aacb228416 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/filters/app.py @@ -50,7 +50,7 @@ __all__ = [ # NOTE: `has_focus` below should *not* be `memoized`. It can reference any user -# control. For instance, if we would contiously create new +# control. For instance, if we would continuously create new # `PromptSession` instances, then previous instances won't be released, # because this memoize (which caches results in the global scope) will # still refer to each instance. 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 e34db13d80..db44ab9266 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 @@ -16,6 +16,7 @@ from .ansi import ANSI from .base import ( AnyFormattedText, FormattedText, + OneStyleAndTextTuple, StyleAndTextTuples, Template, is_formatted_text, @@ -35,6 +36,7 @@ from .utils import ( __all__ = [ # Base. "AnyFormattedText", + "OneStyleAndTextTuple", "to_formatted_text", "is_formatted_text", "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 b242c2cc89..c8c37e0946 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 @@ -72,13 +72,15 @@ def fragment_list_to_text(fragments: StyleAndTextTuples) -> str: return "".join(item[1] for item in fragments if ZeroWidthEscape not in item[0]) -def split_lines(fragments: StyleAndTextTuples) -> Iterable[StyleAndTextTuples]: +def split_lines( + fragments: Iterable[OneStyleAndTextTuple], +) -> Iterable[StyleAndTextTuples]: """ Take a single list of (style_str, text) tuples and yield one such list for each line. Just like str.split, this will yield at least one item. - :param fragments: List of (style_str, text) or (style_str, text, mouse_handler) - tuples. + :param fragments: Iterable of ``(style_str, text)`` or + ``(style_str, text, mouse_handler)`` tuples. """ line: StyleAndTextTuples = [] diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_utils.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_utils.py index e9c73fecc6..4a78dc421b 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_utils.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_utils.py @@ -26,7 +26,7 @@ class PosixStdinReader: On Python3, this can be 'surrogateescape', which is the default. 'surrogateescape' is preferred, because this allows us to transfer - unrecognised bytes to the key bindings. Some terminals, like lxterminal + unrecognized bytes to the key bindings. Some terminals, like lxterminal and Guake, use the 'Mxx' notation to send mouse events, where each 'x' can be any possible byte. """ 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 6abb595daf..62530f2b77 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 @@ -40,8 +40,9 @@ from abc import ABCMeta, abstractmethod, abstractproperty from inspect import isawaitable from typing import ( TYPE_CHECKING, - Awaitable, + Any, Callable, + Coroutine, Hashable, Sequence, Tuple, @@ -89,7 +90,8 @@ __all__ = [ # This is mainly used in case of mouse move events, to prevent excessive # repainting during mouse move events. KeyHandlerCallable = Callable[ - ["KeyPressEvent"], Union["NotImplementedOrNone", Awaitable["NotImplementedOrNone"]] + ["KeyPressEvent"], + Union["NotImplementedOrNone", Coroutine[Any, Any, "NotImplementedOrNone"]], ] @@ -125,7 +127,7 @@ class Binding: # If the handler is a coroutine, create an asyncio task. if isawaitable(result): - awaitable = cast(Awaitable["NotImplementedOrNone"], result) + awaitable = cast(Coroutine[Any, Any, "NotImplementedOrNone"], result) async def bg_task() -> None: result = await awaitable 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 5de87b08a7..100d4aaebc 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/containers.py @@ -2050,7 +2050,7 @@ class Window(Container): new_buffer_row[x + xpos] = char # When we print a multi width character, make sure - # to erase the neighbours positions in the screen. + # to erase the neighbors positions in the screen. # (The empty string if different from everything, # so next redraw this cell will repaint anyway.) if char_width > 1: @@ -2537,7 +2537,7 @@ class Window(Container): scroll_offset_end=offsets.right, cursor_pos=get_cwidth(current_line_text[: ui_content.cursor_position.x]), window_size=width - current_line_prefix_width, - # We can only analyse the current line. Calculating the width off + # We can only analyze the current line. Calculating the width off # all the lines is too expensive. content_size=max( get_cwidth(current_line_text), self.horizontal_scroll + width 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 c13960bc43..c30c0effa8 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/controls.py @@ -491,7 +491,7 @@ class _ProcessedLine(NamedTuple): class BufferControl(UIControl): """ - Control for visualising the content of a :class:`.Buffer`. + Control for visualizing the content of a :class:`.Buffer`. :param buffer: The :class:`.Buffer` object to be displayed. :param input_processors: A list of @@ -603,7 +603,7 @@ class BufferControl(UIControl): width can be done by calculating the longest line, but this would require applying all the processors to each line. This is unfeasible for a larger document, and doing it for small - documents only would result in inconsistent behaviour. + documents only would result in inconsistent behavior. """ return None 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 1a21237a84..2c2ccb6436 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/menus.py @@ -679,7 +679,7 @@ class MultiColumnCompletionsMenu(HSplit): filter=full_filter & show_meta & any_completion_has_meta, ) - # Initialise split. + # Initialize split. super().__init__([completions_window, meta_window], z_index=z_index) 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 90c017ade7..b7376115e4 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/layout/processors.py @@ -288,7 +288,7 @@ class HighlightSelectionProcessor(Processor): if from_ == 0 and to == 0 and len(fragments) == 0: # When this is an empty line, insert a space in order to - # visualise the selection. + # visualize the selection. return Transformation([(selected_fragment, " ")]) else: for i in range(from_, to): 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 16ed29a287..4721d730c8 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/lexers/pygments.py @@ -31,7 +31,7 @@ __all__ = [ class SyntaxSync(metaclass=ABCMeta): """ - Syntax synchroniser. This is a tool that finds a start position for the + Syntax synchronizer. This is a tool that finds a start position for the lexer. This is especially important when editing big documents; we don't want to start the highlighting by running the lexer from the beginning of the file. That is very slow when editing. @@ -67,12 +67,12 @@ class RegexSync(SyntaxSync): Synchronize by starting at a line that matches the given regex pattern. """ - # Never go more than this amount of lines backwards for synchronisation. + # Never go more than this amount of lines backwards for synchronization. # That would be too CPU intensive. MAX_BACKWARDS = 500 # Start lexing at the start, if we are in the first 'n' lines and no - # synchronisation position was found. + # synchronization position was found. FROM_START_IF_NO_SYNC_POS_FOUND = 100 def __init__(self, pattern: str) -> None: @@ -88,13 +88,13 @@ class RegexSync(SyntaxSync): lines = document.lines # Scan upwards, until we find a point where we can start the syntax - # synchronisation. + # synchronization. for i in range(lineno, max(-1, lineno - self.MAX_BACKWARDS), -1): match = pattern.match(lines[i]) if match: return i, match.start() - # No synchronisation point found. If we aren't that far from the + # No synchronization point found. If we aren't that far from the # beginning, start at the very beginning, otherwise, just try to start # at the current line. if lineno < self.FROM_START_IF_NO_SYNC_POS_FOUND: @@ -228,7 +228,7 @@ class PygmentsLexer(Lexer): line_generators: dict[LineGenerator, int] = {} def get_syntax_sync() -> SyntaxSync: - "The Syntax synchronisation object that we currently use." + "The Syntax synchronization object that we currently use." if self.sync_from_start(): return SyncFromStart() else: @@ -271,7 +271,7 @@ class PygmentsLexer(Lexer): return generator # No generator found. Determine starting point for the syntax - # synchronisation first. + # synchronization first. # Go at least x lines back. (Make scrolling upwards more # efficient.) @@ -291,7 +291,7 @@ class PygmentsLexer(Lexer): generator = create_line_generator(row, column) # If the column is not 0, ignore the first line. (Which is - # incomplete. This happens when the synchronisation algorithm tells + # incomplete. This happens when the synchronization algorithm tells # us to start parsing in the middle of a line.) if column: next(generator) @@ -316,7 +316,7 @@ class PygmentsLexer(Lexer): # Remove the next item from the cache. # (It could happen that it's already there, because of # another generator that started filling these lines, - # but we want to synchronise these lines with the + # but we want to synchronize these lines with the # current lexer's state.) if num + 1 in cache: del cache[num + 1] 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 6b06a50eed..3c38cec86e 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/base.py @@ -66,7 +66,7 @@ class Output(metaclass=ABCMeta): @abstractmethod def erase_screen(self) -> None: """ - Erases the screen with the background colour and moves the cursor to + Erases the screen with the background color and moves the cursor to home. """ 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 29743db21d..142deab077 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/output/vt100.py @@ -529,7 +529,7 @@ class Vt100_Output(Output): def erase_screen(self) -> None: """ - Erases the screen with the background colour and moves the cursor to + Erases the screen with the background color and moves the cursor to home. """ self.write_raw("\x1b[2J") 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 81a7ccbb44..528bec7ffe 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/patch_stdout.py @@ -43,7 +43,7 @@ def patch_stdout(raw: bool = False) -> Generator[None, None, None]: Writing to this proxy will make sure that the text appears above the prompt, and that it doesn't destroy the output from the renderer. If no - application is curring, the behaviour should be identical to writing to + application is curring, the behavior should be identical to writing to `sys.stdout` directly. Warning: If a new event loop is installed using `asyncio.set_event_loop()`, @@ -203,6 +203,13 @@ class StdoutProxy: """ def write_and_flush() -> None: + # Ensure that autowrap is enabled before calling `write`. + # XXX: On Windows, the `Windows10_Output` enables/disables VT + # terminal processing for every flush. It turns out that this + # causes autowrap to be reset (disabled) after each flush. So, + # we have to enable it again before writing text. + self._output.enable_autowrap() + if self.raw: self._output.write_raw(text) else: diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py index 7a3b88a608..5ad1dd68d0 100644 --- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py +++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/renderer.py @@ -233,7 +233,7 @@ def _output_screen_diff( # output. That way, we're sure that the terminal scrolls up, even when the # lower lines of the canvas just contain whitespace. - # The most obvious reason that we actually want this behaviour is the avoid + # The most obvious reason that we actually want this behavior is the avoid # the artifact of the input scrolling when the completion menu is shown. # (If the scrolling is actually wanted, the layout can still be build in a # way to behave that way by setting a dynamic height.) diff --git a/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py b/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py index 4a01c0e3d6..8c95f8c087 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_async_generator.py @@ -12,7 +12,7 @@ def _sync_generator(): def test_generator_to_async_generator(): """ - Test conversion of sync to asycn generator. + Test conversion of sync to async generator. This should run the synchronous parts in a background thread. """ async_gen = generator_to_async_generator(_sync_generator) diff --git a/contrib/python/prompt-toolkit/py3/tests/test_formatted_text.py b/contrib/python/prompt-toolkit/py3/tests/test_formatted_text.py index 2d8e184ade..843aac1619 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_formatted_text.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_formatted_text.py @@ -28,7 +28,7 @@ def test_basic_html(): ] # It's important that `to_formatted_text` returns a `FormattedText` - # instance. Otherwise, `print_formatted_text` won't recognise it and will + # instance. Otherwise, `print_formatted_text` won't recognize it and will # print a list literal instead. assert isinstance(to_formatted_text(html), FormattedText) diff --git a/contrib/python/prompt-toolkit/py3/tests/test_widgets.py b/contrib/python/prompt-toolkit/py3/tests/test_widgets.py index 1fc8ae4398..ee7745a2d0 100644 --- a/contrib/python/prompt-toolkit/py3/tests/test_widgets.py +++ b/contrib/python/prompt-toolkit/py3/tests/test_widgets.py @@ -10,7 +10,7 @@ def _to_text(button: Button) -> str: return fragment_list_to_text(control.text()) -def test_defaulf_button(): +def test_default_button(): button = Button("Exit") assert _to_text(button) == "< Exit >" diff --git a/contrib/python/prompt-toolkit/py3/ya.make b/contrib/python/prompt-toolkit/py3/ya.make index 74bf71f6b0..90f446832b 100644 --- a/contrib/python/prompt-toolkit/py3/ya.make +++ b/contrib/python/prompt-toolkit/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(3.0.41) +VERSION(3.0.43) LICENSE(BSD-3-Clause) |