diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-14 17:46:04 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-06-14 18:00:06 +0300 |
commit | 85f6451860166545196ffa2950aa68be2363733b (patch) | |
tree | 4443b7b2465bda4bdc3589314f258329ecaedb38 /contrib/python/prompt-toolkit/py3/prompt_toolkit/layout | |
parent | fa297dd4855aef4bd79faebb48120708d2f9249d (diff) | |
download | ydb-85f6451860166545196ffa2950aa68be2363733b.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/layout')
12 files changed, 38 insertions, 51 deletions
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] |