diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
commit | 5b43aaac61ac94abe722bc98ae58468618f2f512 (patch) | |
tree | 3d58c89faa23d194f83abb24ae1fd05067538fff /src/prompt_toolkit/layout | |
parent | Adding upstream version 3.0.43. (diff) | |
download | prompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.tar.xz prompt-toolkit-5b43aaac61ac94abe722bc98ae58468618f2f512.zip |
Adding upstream version 3.0.46.upstream/3.0.46
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/prompt_toolkit/layout')
-rw-r--r-- | src/prompt_toolkit/layout/__init__.py | 1 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/containers.py | 33 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/controls.py | 1 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/dimension.py | 11 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/dummy.py | 1 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/layout.py | 1 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/margins.py | 3 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/menus.py | 5 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/mouse_handlers.py | 6 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/processors.py | 13 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/screen.py | 8 | ||||
-rw-r--r-- | src/prompt_toolkit/layout/utils.py | 6 |
12 files changed, 38 insertions, 51 deletions
diff --git a/src/prompt_toolkit/layout/__init__.py b/src/prompt_toolkit/layout/__init__.py index c5fce46..7cd0c77 100644 --- a/src/prompt_toolkit/layout/__init__.py +++ b/src/prompt_toolkit/layout/__init__.py @@ -44,6 +44,7 @@ And one prepared menu: - CompletionsMenu """ + from __future__ import annotations from .containers import ( diff --git a/src/prompt_toolkit/layout/containers.py b/src/prompt_toolkit/layout/containers.py index 100d4aa..99b4534 100644 --- a/src/prompt_toolkit/layout/containers.py +++ b/src/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/src/prompt_toolkit/layout/controls.py b/src/prompt_toolkit/layout/controls.py index c30c0ef..222e471 100644 --- a/src/prompt_toolkit/layout/controls.py +++ b/src/prompt_toolkit/layout/controls.py @@ -1,6 +1,7 @@ """ User interface Controls for the layout. """ + from __future__ import annotations import time diff --git a/src/prompt_toolkit/layout/dimension.py b/src/prompt_toolkit/layout/dimension.py index c1f05f9..2e6f5dd 100644 --- a/src/prompt_toolkit/layout/dimension.py +++ b/src/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/src/prompt_toolkit/layout/dummy.py b/src/prompt_toolkit/layout/dummy.py index 139f311..1ee3e6c 100644 --- a/src/prompt_toolkit/layout/dummy.py +++ b/src/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/src/prompt_toolkit/layout/layout.py b/src/prompt_toolkit/layout/layout.py index a5e7a80..f9b7110 100644 --- a/src/prompt_toolkit/layout/layout.py +++ b/src/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/src/prompt_toolkit/layout/margins.py b/src/prompt_toolkit/layout/margins.py index cc9dd96..737a74d 100644 --- a/src/prompt_toolkit/layout/margins.py +++ b/src/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/src/prompt_toolkit/layout/menus.py b/src/prompt_toolkit/layout/menus.py index 2c2ccb6..612e8ab 100644 --- a/src/prompt_toolkit/layout/menus.py +++ b/src/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/src/prompt_toolkit/layout/mouse_handlers.py b/src/prompt_toolkit/layout/mouse_handlers.py index 56a4edd..52deac1 100644 --- a/src/prompt_toolkit/layout/mouse_handlers.py +++ b/src/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/src/prompt_toolkit/layout/processors.py b/src/prompt_toolkit/layout/processors.py index b737611..b10ecf7 100644 --- a/src/prompt_toolkit/layout/processors.py +++ b/src/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/src/prompt_toolkit/layout/screen.py b/src/prompt_toolkit/layout/screen.py index 49aebbd..0f19f52 100644 --- a/src/prompt_toolkit/layout/screen.py +++ b/src/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/src/prompt_toolkit/layout/utils.py b/src/prompt_toolkit/layout/utils.py index 0f78f37..373fe52 100644 --- a/src/prompt_toolkit/layout/utils.py +++ b/src/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] |