From 7ff61b64036e536d4f065882c1d7fa792449cae5 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sat, 1 Oct 2022 13:53:03 -0400 Subject: [PATCH 01/17] Add type stubs for package console-menu. --- pyrightconfig.stricter.json | 1 + stubs/console-menu/METADATA.toml | 4 + stubs/console-menu/consolemenu/__init__.pyi | 6 + .../console-menu/consolemenu/console_menu.pyi | 86 ++++++++ .../consolemenu/format/__init__.pyi | 14 ++ .../consolemenu/format/menu_borders.pyi | 194 ++++++++++++++++++ .../consolemenu/format/menu_margins.pyi | 18 ++ .../consolemenu/format/menu_padding.pyi | 18 ++ .../consolemenu/format/menu_style.pyi | 29 +++ .../consolemenu/items/__init__.pyi | 6 + .../consolemenu/items/command_item.pyi | 12 ++ .../consolemenu/items/external_item.pyi | 7 + .../consolemenu/items/function_item.pyi | 23 +++ .../consolemenu/items/selection_item.pyi | 9 + .../consolemenu/items/submenu_item.pyi | 13 ++ .../consolemenu/menu_component.pyi | 99 +++++++++ .../consolemenu/menu_formatter.pyi | 55 +++++ .../consolemenu/multiselect_menu.pyi | 22 ++ .../console-menu/consolemenu/prompt_utils.pyi | 46 +++++ stubs/console-menu/consolemenu/screen.pyi | 17 ++ .../consolemenu/selection_menu.pyi | 29 +++ .../consolemenu/validators/__init__.pyi | 0 .../consolemenu/validators/base.pyi | 11 + .../consolemenu/validators/regex.pyi | 7 + .../consolemenu/validators/url.pyi | 5 + stubs/console-menu/consolemenu/version.pyi | 0 26 files changed, 731 insertions(+) create mode 100644 stubs/console-menu/METADATA.toml create mode 100644 stubs/console-menu/consolemenu/__init__.pyi create mode 100644 stubs/console-menu/consolemenu/console_menu.pyi create mode 100644 stubs/console-menu/consolemenu/format/__init__.pyi create mode 100644 stubs/console-menu/consolemenu/format/menu_borders.pyi create mode 100644 stubs/console-menu/consolemenu/format/menu_margins.pyi create mode 100644 stubs/console-menu/consolemenu/format/menu_padding.pyi create mode 100644 stubs/console-menu/consolemenu/format/menu_style.pyi create mode 100644 stubs/console-menu/consolemenu/items/__init__.pyi create mode 100644 stubs/console-menu/consolemenu/items/command_item.pyi create mode 100644 stubs/console-menu/consolemenu/items/external_item.pyi create mode 100644 stubs/console-menu/consolemenu/items/function_item.pyi create mode 100644 stubs/console-menu/consolemenu/items/selection_item.pyi create mode 100644 stubs/console-menu/consolemenu/items/submenu_item.pyi create mode 100644 stubs/console-menu/consolemenu/menu_component.pyi create mode 100644 stubs/console-menu/consolemenu/menu_formatter.pyi create mode 100644 stubs/console-menu/consolemenu/multiselect_menu.pyi create mode 100644 stubs/console-menu/consolemenu/prompt_utils.pyi create mode 100644 stubs/console-menu/consolemenu/screen.pyi create mode 100644 stubs/console-menu/consolemenu/selection_menu.pyi create mode 100644 stubs/console-menu/consolemenu/validators/__init__.pyi create mode 100644 stubs/console-menu/consolemenu/validators/base.pyi create mode 100644 stubs/console-menu/consolemenu/validators/regex.pyi create mode 100644 stubs/console-menu/consolemenu/validators/url.pyi create mode 100644 stubs/console-menu/consolemenu/version.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 5db60697d1aa..9fddab8d90df 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -38,6 +38,7 @@ "stubs/caldav", "stubs/cffi", "stubs/commonmark", + "stubs/console-menu", "stubs/cryptography", "stubs/dateparser", "stubs/dj-database-url", diff --git a/stubs/console-menu/METADATA.toml b/stubs/console-menu/METADATA.toml new file mode 100644 index 000000000000..161ee7abb397 --- /dev/null +++ b/stubs/console-menu/METADATA.toml @@ -0,0 +1,4 @@ +version = "0.7.*" + +[tool.stubtest] +ignore_missing_stub = false diff --git a/stubs/console-menu/consolemenu/__init__.pyi b/stubs/console-menu/consolemenu/__init__.pyi new file mode 100644 index 000000000000..8bc6c6cd7460 --- /dev/null +++ b/stubs/console-menu/consolemenu/__init__.pyi @@ -0,0 +1,6 @@ +from . import items as items +from .console_menu import ConsoleMenu as ConsoleMenu, Screen as Screen, clear_terminal as clear_terminal +from .menu_formatter import MenuFormatBuilder as MenuFormatBuilder +from .multiselect_menu import MultiSelectMenu as MultiSelectMenu +from .prompt_utils import PromptUtils as PromptUtils +from .selection_menu import SelectionMenu as SelectionMenu diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi new file mode 100644 index 000000000000..916e3e2c7b88 --- /dev/null +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -0,0 +1,86 @@ +from consolemenu.menu_formatter import MenuFormatBuilder as MenuFormatBuilder +from consolemenu.screen import Screen as Screen + +class ConsoleMenu: + currently_active_menu: ConsoleMenu | None + screen: Screen + clear_screen_before_render: bool + formatter: MenuFormatBuilder + title: str | None + subtitle: str | None + prologue_text: str | None + epilogue_text: str | None + highlight: None + normal: None + show_exit_option: bool + items: list[MenuItem] + parent: ConsoleMenu + exit_item: ExitItem + current_option: int + selected_option: int + returned_value: object + should_exit: bool + previous_active_menu: ConsoleMenu + def __init__( + self, + title: str | None = ..., + subtitle: str | None = ..., + screen: Screen | None = ..., + formatter: MenuFormatBuilder | None = ..., + prologue_text: str | None = ..., + epilogue_text: str | None = ..., + clear_screen: bool = ..., + show_exit_option: bool = ..., + exit_option_text: str = ..., + ) -> None: ... + @property + def current_item(self) -> MenuItem: ... + @property + def selected_item(self) -> MenuItem: ... + def append_item(self, item: MenuItem) -> None: ... + def remove_item(self, item: MenuItem) -> bool: ... + def add_exit(self) -> bool: ... + def remove_exit(self) -> bool: ... + def is_selected_item_exit(self) -> bool: ... + def start(self, show_exit_option: bool | None = ...) -> None: ... + def show(self, show_exit_option: bool | None = ...) -> None: ... + def draw(self) -> None: ... + def is_running(self) -> bool: ... + def wait_for_start(self, timeout: float | None = ...) -> bool: ... + def is_alive(self) -> bool: ... + def pause(self) -> None: ... + def resume(self) -> None: ... + def join(self, timeout: float | None = ...) -> None: ... + def get_input(self) -> int: ... + def process_user_input(self) -> int | None: ... + def go_to(self, option: int) -> None: ... + def go_down(self) -> None: ... + def go_up(self) -> None: ... + def select(self) -> None: ... + def exit(self) -> None: ... + def clear_screen(self) -> None: ... + def get_title(self) -> str: ... + def get_subtitle(self) -> str: ... + def get_prologue_text(self) -> str: ... + def get_epilogue_text(self) -> str: ... + +class MenuItem: + text: str + menu: ConsoleMenu + should_exit: bool + index_item_separator: str + def __init__(self, text: str, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + def show(self, index: int) -> str: ... + def set_up(self) -> None: ... + def action(self) -> None: ... + def clean_up(self) -> None: ... + def get_return(self) -> object: ... + def __eq__(self, o: MenuItem) -> bool: ... # type: ignore[override] + def get_text(self) -> str: ... + +class ExitItem(MenuItem): + def __init__(self, text: str = ..., menu: ConsoleMenu | None = ...) -> None: ... + text: str + def show(self, index: int, available_width: None = ...): ... + +def clear_terminal() -> None: ... diff --git a/stubs/console-menu/consolemenu/format/__init__.pyi b/stubs/console-menu/consolemenu/format/__init__.pyi new file mode 100644 index 000000000000..f43b6c56360a --- /dev/null +++ b/stubs/console-menu/consolemenu/format/__init__.pyi @@ -0,0 +1,14 @@ +from .menu_borders import ( + AsciiBorderStyle as AsciiBorderStyle, + DoubleLineBorderStyle as DoubleLineBorderStyle, + DoubleLineOuterLightInnerBorderStyle as DoubleLineOuterLightInnerBorderStyle, + HeavyBorderStyle as HeavyBorderStyle, + HeavyOuterLightInnerBorderStyle as HeavyOuterLightInnerBorderStyle, + LightBorderStyle as LightBorderStyle, + MenuBorderStyle as MenuBorderStyle, + MenuBorderStyleFactory as MenuBorderStyleFactory, + MenuBorderStyleType as MenuBorderStyleType, +) +from .menu_margins import MenuMargins as MenuMargins +from .menu_padding import MenuPadding as MenuPadding +from .menu_style import MenuStyle as MenuStyle diff --git a/stubs/console-menu/consolemenu/format/menu_borders.pyi b/stubs/console-menu/consolemenu/format/menu_borders.pyi new file mode 100644 index 000000000000..21eb4a43f395 --- /dev/null +++ b/stubs/console-menu/consolemenu/format/menu_borders.pyi @@ -0,0 +1,194 @@ +from _typeshed import Incomplete + +class MenuBorderStyle: + @property + def bottom_left_corner(self) -> str: ... + @property + def bottom_right_corner(self) -> str: ... + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + @property + def top_left_corner(self) -> str: ... + @property + def top_right_corner(self) -> str: ... + +class AsciiBorderStyle(MenuBorderStyle): + @property + def bottom_left_corner(self) -> str: ... + @property + def bottom_right_corner(self) -> str: ... + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + @property + def top_left_corner(self) -> str: ... + @property + def top_right_corner(self) -> str: ... + +class LightBorderStyle(MenuBorderStyle): + @property + def bottom_left_corner(self) -> str: ... + @property + def bottom_right_corner(self) -> str: ... + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + @property + def top_left_corner(self) -> str: ... + @property + def top_right_corner(self) -> str: ... + +class HeavyBorderStyle(MenuBorderStyle): + @property + def bottom_left_corner(self) -> str: ... + @property + def bottom_right_corner(self) -> str: ... + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + @property + def top_left_corner(self) -> str: ... + @property + def top_right_corner(self) -> str: ... + +class HeavyOuterLightInnerBorderStyle(HeavyBorderStyle): + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + +class DoubleLineBorderStyle(MenuBorderStyle): + @property + def bottom_left_corner(self) -> str: ... + @property + def bottom_right_corner(self) -> str: ... + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + @property + def top_left_corner(self) -> str: ... + @property + def top_right_corner(self) -> str: ... + +class DoubleLineOuterLightInnerBorderStyle(DoubleLineBorderStyle): + @property + def inner_horizontal(self) -> str: ... + @property + def inner_vertical(self) -> str: ... + @property + def intersection(self) -> str: ... + @property + def outer_horizontal_inner_down(self) -> str: ... + @property + def outer_horizontal_inner_up(self) -> str: ... + @property + def outer_vertical_inner_left(self) -> str: ... + @property + def outer_vertical_inner_right(self) -> str: ... + +class MenuBorderStyleType: + ASCII_BORDER: int + LIGHT_BORDER: int + HEAVY_BORDER: int + DOUBLE_LINE_BORDER: int + HEAVY_OUTER_LIGHT_INNER_BORDER: int + DOUBLE_LINE_OUTER_LIGHT_INNER_BORDER: int + +class MenuBorderStyleFactory: + logger: Incomplete + def __init__(self) -> None: ... + def create_border(self, border_style_type: MenuBorderStyleType): ... + def create_ascii_border(self) -> AsciiBorderStyle: ... + def create_light_border(self) -> LightBorderStyle: ... + def create_heavy_border(self) -> HeavyBorderStyle: ... + def create_heavy_outer_light_inner_border(self) -> HeavyOuterLightInnerBorderStyle: ... + def create_doubleline_border(self) -> DoubleLineBorderStyle: ... + def create_doubleline_outer_light_inner_border(self) -> DoubleLineOuterLightInnerBorderStyle: ... + @staticmethod + def is_win_python35_or_earlier() -> bool: ... diff --git a/stubs/console-menu/consolemenu/format/menu_margins.pyi b/stubs/console-menu/consolemenu/format/menu_margins.pyi new file mode 100644 index 000000000000..f37b333862a8 --- /dev/null +++ b/stubs/console-menu/consolemenu/format/menu_margins.pyi @@ -0,0 +1,18 @@ +class MenuMargins: + def __init__(self, top: int = ..., left: int = ..., bottom: int = ..., right: int = ...) -> None: ... + @property + def left(self) -> int: ... + @left.setter + def left(self, left: int) -> None: ... + @property + def right(self) -> int: ... + @right.setter + def right(self, right: int) -> None: ... + @property + def top(self) -> int: ... + @top.setter + def top(self, top: int) -> None: ... + @property + def bottom(self) -> int: ... + @bottom.setter + def bottom(self, bottom: int) -> None: ... diff --git a/stubs/console-menu/consolemenu/format/menu_padding.pyi b/stubs/console-menu/consolemenu/format/menu_padding.pyi new file mode 100644 index 000000000000..46855b29df6b --- /dev/null +++ b/stubs/console-menu/consolemenu/format/menu_padding.pyi @@ -0,0 +1,18 @@ +class MenuPadding: + def __init__(self, top: int = ..., left: int = ..., bottom: int = ..., right: int = ...) -> None: ... + @property + def left(self) -> int: ... + @left.setter + def left(self, left: int) -> None: ... + @property + def right(self) -> int: ... + @right.setter + def right(self, right: int) -> None: ... + @property + def top(self) -> int: ... + @top.setter + def top(self, top: int) -> None: ... + @property + def bottom(self) -> int: ... + @bottom.setter + def bottom(self, bottom: int) -> None: ... diff --git a/stubs/console-menu/consolemenu/format/menu_style.pyi b/stubs/console-menu/consolemenu/format/menu_style.pyi new file mode 100644 index 000000000000..e7e3c11c174e --- /dev/null +++ b/stubs/console-menu/consolemenu/format/menu_style.pyi @@ -0,0 +1,29 @@ +from consolemenu.format.menu_borders import MenuBorderStyle as MenuBorderStyle, MenuBorderStyleFactory as MenuBorderStyleFactory +from consolemenu.format.menu_margins import MenuMargins as MenuMargins +from consolemenu.format.menu_padding import MenuPadding as MenuPadding + +class MenuStyle: + def __init__( + self, + margins: MenuMargins | None = ..., + padding: MenuPadding | None = ..., + border_style: MenuBorderStyle | None = ..., + border_style_type: int | None = ..., + border_style_factory: MenuBorderStyleFactory | None = ..., + ) -> None: ... + @property + def margins(self) -> MenuMargins: ... + @margins.setter + def margins(self, margins: MenuMargins) -> None: ... + @property + def padding(self) -> MenuPadding: ... + @padding.setter + def padding(self, padding: MenuPadding) -> None: ... + @property + def border_style(self) -> MenuBorderStyle: ... + @border_style.setter + def border_style(self, border_style: MenuBorderStyle) -> None: ... + @property + def border_style_factory(self) -> MenuBorderStyleFactory: ... + @border_style_factory.setter + def border_style_factory(self, border_style_factory: MenuBorderStyleFactory) -> None: ... diff --git a/stubs/console-menu/consolemenu/items/__init__.pyi b/stubs/console-menu/consolemenu/items/__init__.pyi new file mode 100644 index 000000000000..570ff3f5e422 --- /dev/null +++ b/stubs/console-menu/consolemenu/items/__init__.pyi @@ -0,0 +1,6 @@ +from ..console_menu import ExitItem as ExitItem, MenuItem as MenuItem +from .command_item import CommandItem as CommandItem +from .external_item import ExternalItem as ExternalItem +from .function_item import FunctionItem as FunctionItem +from .selection_item import SelectionItem as SelectionItem +from .submenu_item import SubmenuItem as SubmenuItem diff --git a/stubs/console-menu/consolemenu/items/command_item.pyi b/stubs/console-menu/consolemenu/items/command_item.pyi new file mode 100644 index 000000000000..f44003f84637 --- /dev/null +++ b/stubs/console-menu/consolemenu/items/command_item.pyi @@ -0,0 +1,12 @@ +from consolemenu.console_menu import ConsoleMenu +from consolemenu.items import ExternalItem as ExternalItem + +class CommandItem(ExternalItem): + command: str + arguments: list[str] + exit_status: int | None + def __init__( + self, text: str, command: str, arguments: list[str] | None = ..., menu: ConsoleMenu | None = ..., should_exit: bool = ... + ) -> None: ... + def action(self) -> None: ... + def get_return(self) -> int: ... diff --git a/stubs/console-menu/consolemenu/items/external_item.pyi b/stubs/console-menu/consolemenu/items/external_item.pyi new file mode 100644 index 000000000000..72ec0187e9b5 --- /dev/null +++ b/stubs/console-menu/consolemenu/items/external_item.pyi @@ -0,0 +1,7 @@ +from consolemenu.console_menu import ConsoleMenu +from consolemenu.items import MenuItem as MenuItem + +class ExternalItem(MenuItem): + def __init__(self, text: str, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + def set_up(self) -> None: ... + def clean_up(self) -> None: ... diff --git a/stubs/console-menu/consolemenu/items/function_item.pyi b/stubs/console-menu/consolemenu/items/function_item.pyi new file mode 100644 index 000000000000..3fa665cf789f --- /dev/null +++ b/stubs/console-menu/consolemenu/items/function_item.pyi @@ -0,0 +1,23 @@ +from typing import Any +from collections.abc import Callable + +from consolemenu.console_menu import ConsoleMenu +from consolemenu.items import ExternalItem as ExternalItem + +class FunctionItem(ExternalItem): + function: Callable[..., Any] + args: list[Any] + kwargs: dict[str, Any] + return_value: Any | None + def __init__( + self, + text: str, + function: Callable[[Any], Any], + args: list[Any] | None = ..., + kwargs: dict[str, Any] | None = ..., + menu: ConsoleMenu | None = ..., + should_exit: bool = ..., + ) -> None: ... + def action(self) -> None: ... + def clean_up(self) -> None: ... + def get_return(self) -> Any | None: ... diff --git a/stubs/console-menu/consolemenu/items/selection_item.pyi b/stubs/console-menu/consolemenu/items/selection_item.pyi new file mode 100644 index 000000000000..423aafbaffd7 --- /dev/null +++ b/stubs/console-menu/consolemenu/items/selection_item.pyi @@ -0,0 +1,9 @@ +from _typeshed import Incomplete + +from consolemenu.console_menu import ConsoleMenu +from consolemenu.items import MenuItem as MenuItem + +class SelectionItem(MenuItem): + index: Incomplete + def __init__(self, text: str, index: int, menu: ConsoleMenu | None = ...) -> None: ... + def get_return(self) -> int: ... diff --git a/stubs/console-menu/consolemenu/items/submenu_item.pyi b/stubs/console-menu/consolemenu/items/submenu_item.pyi new file mode 100644 index 000000000000..7a7623ce584f --- /dev/null +++ b/stubs/console-menu/consolemenu/items/submenu_item.pyi @@ -0,0 +1,13 @@ +from consolemenu.console_menu import ConsoleMenu +from consolemenu.items import MenuItem as MenuItem + +class SubmenuItem(MenuItem): + submenu: ConsoleMenu + def __init__(self, text: str, submenu: ConsoleMenu, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + menu: ConsoleMenu + def set_menu(self, menu: ConsoleMenu) -> None: ... + def set_up(self) -> None: ... + def action(self) -> None: ... + def clean_up(self) -> None: ... + def get_return(self) -> int: ... + def get_submenu(self) -> ConsoleMenu: ... diff --git a/stubs/console-menu/consolemenu/menu_component.pyi b/stubs/console-menu/consolemenu/menu_component.pyi new file mode 100644 index 000000000000..651483650f90 --- /dev/null +++ b/stubs/console-menu/consolemenu/menu_component.pyi @@ -0,0 +1,99 @@ +from collections.abc import Generator + +from consolemenu.console_menu import MenuItem +from consolemenu.format import MenuBorderStyle, MenuMargins, MenuPadding, MenuStyle as MenuStyle + +def ansilen(s: str) -> int: ... + +class Dimension: + width: int + height: int + def __init__(self, width: int = ..., height: int = ..., dimension: Dimension | None = ...) -> None: ... + +class MenuComponent: + def __init__(self, menu_style: MenuStyle, max_dimension: Dimension | None = ...) -> None: ... + @property + def max_dimension(self) -> Dimension: ... + @property + def style(self) -> MenuStyle: ... + @property + def margins(self) -> MenuMargins: ... + @property + def padding(self) -> MenuPadding: ... + @property + def border_style(self) -> MenuBorderStyle: ... + def calculate_border_width(self) -> int: ... + def calculate_content_width(self) -> int: ... + def generate(self) -> Generator[str, None, None]: ... + def inner_horizontals(self) -> str: ... + def inner_horizontal_border(self) -> str: ... + def outer_horizontals(self) -> str: ... + def outer_horizontal_border_bottom(self) -> str: ... + def outer_horizontal_border_top(self) -> str: ... + def row(self, content: str = ..., align: str = ..., indent_len: int = ...) -> str: ... + +class MenuHeader(MenuComponent): + title: str + title_align: str + subtitle: str + subtitle_align: str + show_bottom_border: bool + def __init__( + self, + menu_style: MenuStyle, + max_dimension: Dimension | None = ..., + title: str | None = ..., + title_align: str = ..., + subtitle: str | None = ..., + subtitle_align: str = ..., + show_bottom_border: bool = ..., + ) -> None: ... + def generate(self) -> Generator[str, None, None]: ... + +class MenuTextSection(MenuComponent): + text: str + text_align: str + show_top_border: bool + show_bottom_border: bool + def __init__( + self, + menu_style: MenuStyle, + max_dimension: Dimension | None = ..., + text: str | None = ..., + text_align: str = ..., + show_top_border: bool = ..., + show_bottom_border: bool = ..., + ) -> None: ... + def generate(self) -> Generator[str, None, None]: ... + +class MenuItemsSection(MenuComponent): + items_align: str + def __init__( + self, + menu_style: MenuStyle, + max_dimension: Dimension | None = ..., + items: list[MenuItem] | None = ..., + items_align: str = ..., + ) -> None: ... + @property + def items(self) -> list[MenuItem]: ... + @items.setter + def items(self, items: list[MenuItem]) -> None: ... + @property + def items_with_bottom_border(self) -> list[str]: ... + @property + def items_with_top_border(self) -> list[str]: ... + def show_item_bottom_border(self, item_text: str, flag: bool) -> None: ... + def show_item_top_border(self, item_text: str, flag: bool) -> None: ... + def generate(self) -> Generator[str, None, None]: ... + +class MenuFooter(MenuComponent): + def generate(self) -> Generator[str, None, None]: ... + +class MenuPrompt(MenuComponent): + def __init__(self, menu_style: MenuStyle, max_dimension: Dimension | None = ..., prompt_string: str = ...) -> None: ... + @property + def prompt(self) -> str: ... + @prompt.setter + def prompt(self, prompt: str) -> None: ... + def generate(self) -> Generator[str, None, None]: ... diff --git a/stubs/console-menu/consolemenu/menu_formatter.pyi b/stubs/console-menu/consolemenu/menu_formatter.pyi new file mode 100644 index 000000000000..cfd09a695916 --- /dev/null +++ b/stubs/console-menu/consolemenu/menu_formatter.pyi @@ -0,0 +1,55 @@ +from consolemenu.console_menu import MenuItem +from consolemenu.format import MenuBorderStyleType +from consolemenu.format.menu_borders import MenuBorderStyle as MenuBorderStyle, MenuBorderStyleFactory as MenuBorderStyleFactory +from consolemenu.format.menu_style import MenuStyle as MenuStyle +from consolemenu.menu_component import ( + Dimension as Dimension, + MenuFooter as MenuFooter, + MenuHeader as MenuHeader, + MenuItemsSection as MenuItemsSection, + MenuPrompt as MenuPrompt, + MenuTextSection as MenuTextSection, +) + +class MenuFormatBuilder: + def __init__(self, max_dimension: Dimension | None = ...) -> None: ... + def set_border_style(self, border_style: MenuBorderStyle) -> MenuFormatBuilder: ... + def set_border_style_type(self, border_style_type: MenuBorderStyleType) -> MenuFormatBuilder: ... + def set_border_style_factory(self, border_style_factory: MenuBorderStyleFactory) -> MenuFormatBuilder: ... + def set_bottom_margin(self, bottom_margin: int) -> MenuFormatBuilder: ... + def set_left_margin(self, left_margin: int) -> MenuFormatBuilder: ... + def set_right_margin(self, right_margin: int) -> MenuFormatBuilder: ... + def set_top_margin(self, top_margin: int) -> MenuFormatBuilder: ... + def set_title_align(self, align: str = ...) -> MenuFormatBuilder: ... + def set_subtitle_align(self, align: str = ...) -> MenuFormatBuilder: ... + def set_header_left_padding(self, x: int) -> MenuFormatBuilder: ... + def set_header_right_padding(self, x: int) -> MenuFormatBuilder: ... + def set_header_bottom_padding(self, x: int) -> MenuFormatBuilder: ... + def set_header_top_padding(self, x: int) -> MenuFormatBuilder: ... + def show_header_bottom_border(self, flag: bool) -> MenuFormatBuilder: ... + def set_footer_left_padding(self, x: int) -> MenuFormatBuilder: ... + def set_footer_right_padding(self, x: int) -> MenuFormatBuilder: ... + def set_footer_bottom_padding(self, x: int) -> MenuFormatBuilder: ... + def set_footer_top_padding(self, x: int) -> MenuFormatBuilder: ... + def set_items_left_padding(self, x: int) -> MenuFormatBuilder: ... + def set_items_right_padding(self, x: int) -> MenuFormatBuilder: ... + def set_items_bottom_padding(self, x: int) -> MenuFormatBuilder: ... + def set_items_top_padding(self, x: int) -> MenuFormatBuilder: ... + def show_item_bottom_border(self, item_text: str, flag: bool) -> MenuFormatBuilder: ... + def show_item_top_border(self, item_text: str, flag: bool) -> MenuFormatBuilder: ... + def set_prologue_text_align(self, align: str = ...) -> MenuFormatBuilder: ... + def show_prologue_top_border(self, flag: bool) -> MenuFormatBuilder: ... + def show_prologue_bottom_border(self, flag: bool) -> MenuFormatBuilder: ... + def set_epilogue_text_align(self, align: str = ...) -> MenuFormatBuilder: ... + def show_epilogue_top_border(self, flag: bool) -> MenuFormatBuilder: ... + def show_epilogue_bottom_border(self, flag: bool) -> MenuFormatBuilder: ... + def set_prompt(self, prompt: MenuPrompt) -> MenuFormatBuilder: ... + def clear_data(self) -> None: ... + def format( + self, + title: str | None = ..., + subtitle: str | None = ..., + prologue_text: str | None = ..., + epilogue_text: str | None = ..., + items: list[MenuItem] | None = ..., + ) -> str: ... diff --git a/stubs/console-menu/consolemenu/multiselect_menu.pyi b/stubs/console-menu/consolemenu/multiselect_menu.pyi new file mode 100644 index 000000000000..06e2a5e75185 --- /dev/null +++ b/stubs/console-menu/consolemenu/multiselect_menu.pyi @@ -0,0 +1,22 @@ +from consolemenu import ConsoleMenu as ConsoleMenu +from consolemenu.console_menu import MenuItem +from consolemenu.items import SubmenuItem as SubmenuItem +from consolemenu.menu_formatter import MenuFormatBuilder + +class MultiSelectMenu(ConsoleMenu): + ack_item_completion: bool + def __init__( + self, + title: str | None = ..., + subtitle: str | None = ..., + formatter: MenuFormatBuilder | None = ..., + prologue_text: str | None = ..., + epilogue_text: str | None = ..., + ack_item_completion: bool = ..., + show_exit_option: bool = ..., + exit_option_text: str = ..., + clear_screen: bool = ..., + ) -> None: ... + def append_item(self, item: MenuItem) -> None: ... + current_option: int + def process_user_input(self) -> None: ... diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi new file mode 100644 index 000000000000..0366fb514187 --- /dev/null +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -0,0 +1,46 @@ +from typing import Any, NamedTuple + +from consolemenu.screen import Screen +from consolemenu.validators.base import BaseValidator as BaseValidator, InvalidValidator as InvalidValidator + +class InputResult(NamedTuple): + input_string: str + validation_result: bool + +class PromptFormatter: + @staticmethod + def format_prompt( + prompt: str | None = ..., + default: str | None = ..., + enable_quit: bool = ..., + quit_string: str = ..., + quit_message: str = ..., + ) -> str: ... + +class PromptUtils: + def __init__(self, screen: Screen, prompt_formatter: PromptFormatter | None = ...) -> None: ... + @property + def screen(self) -> Screen: ... + def clear(self) -> None: ... + def confirm_answer(self, answer: str, message: str | None = ...) -> bool: ... + def enter_to_continue(self, message: str | None = ...) -> None: ... + def input( + self, + prompt: str | None = ..., + default: str | None = ..., + validators: list[BaseValidator] | None = ..., + enable_quit: bool = ..., + quit_string: str = ..., + quit_message: str = ..., + ) -> InputResult: ... + def input_password(self, message: str | None = ...) -> str: ... + def printf(self, *args: list[Any]) -> None: ... + def println(self, *args: list[Any]) -> None: ... + def prompt_and_confirm_password(self, message: str) -> str: ... + def prompt_for_bilateral_choice(self, prompt: str, option1: str, option2: str) -> str: ... + def prompt_for_trilateral_choice(self, prompt: str, option1: str, option2: str, option3: str) -> str: ... + def prompt_for_yes_or_no(self, prompt: str) -> bool: ... + def prompt_for_numbered_choice(self, choices: list[str], title: str | None = ..., prompt: str = ...) -> int: ... + def validate_input(self, input_string: str, validators: BaseValidator) -> bool: ... + +class UserQuit(Exception): ... diff --git a/stubs/console-menu/consolemenu/screen.pyi b/stubs/console-menu/consolemenu/screen.pyi new file mode 100644 index 000000000000..5fc3cd4038bc --- /dev/null +++ b/stubs/console-menu/consolemenu/screen.pyi @@ -0,0 +1,17 @@ +from typing import Any + +class Screen: + def __init__(self) -> None: ... + @property + def screen_height(self) -> int: ... + @property + def screen_width(self) -> int: ... + @staticmethod + def clear() -> None: ... + @staticmethod + def flush() -> None: ... + def input(self, prompt: str = ...) -> str: ... + @staticmethod + def printf(*args: list[Any]) -> None: ... + @staticmethod + def println(*args: list[Any]) -> None: ... diff --git a/stubs/console-menu/consolemenu/selection_menu.pyi b/stubs/console-menu/consolemenu/selection_menu.pyi new file mode 100644 index 000000000000..335b137c00a9 --- /dev/null +++ b/stubs/console-menu/consolemenu/selection_menu.pyi @@ -0,0 +1,29 @@ +from consolemenu import ConsoleMenu as ConsoleMenu +from consolemenu.items import SelectionItem as SelectionItem +from consolemenu.menu_formatter import MenuFormatBuilder +from consolemenu.screen import Screen + +class SelectionMenu(ConsoleMenu): + def __init__( + self, + strings: list[str], + title: str | None = ..., + subtitle: str | None = ..., + screen: Screen | None = ..., + formatter: MenuFormatBuilder | None = ..., + prologue_text: str | None = ..., + epilogue_text: str | None = ..., + show_exit_option: bool = ..., + exit_option_text: str = ..., + clear_screen: bool = ..., + ) -> None: ... + @classmethod + def get_selection( + cls, + strings: list[str], + title: str = ..., + subtitle: str | None = ..., + show_exit_option: bool = ..., + _menu: ConsoleMenu | None = ..., + ) -> int: ... + def append_string(self, string: str) -> None: ... diff --git a/stubs/console-menu/consolemenu/validators/__init__.pyi b/stubs/console-menu/consolemenu/validators/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/console-menu/consolemenu/validators/base.pyi b/stubs/console-menu/consolemenu/validators/base.pyi new file mode 100644 index 000000000000..eaea5c87caec --- /dev/null +++ b/stubs/console-menu/consolemenu/validators/base.pyi @@ -0,0 +1,11 @@ +import abc +from abc import abstractmethod +from logging import Logger + +class InvalidValidator(Exception): ... + +class BaseValidator(metaclass=abc.ABCMeta): + log: Logger + def __init__(self) -> None: ... + @abstractmethod + def validate(self, input_string: str) -> bool: ... diff --git a/stubs/console-menu/consolemenu/validators/regex.pyi b/stubs/console-menu/consolemenu/validators/regex.pyi new file mode 100644 index 000000000000..fdadc44f6720 --- /dev/null +++ b/stubs/console-menu/consolemenu/validators/regex.pyi @@ -0,0 +1,7 @@ +from consolemenu.validators.base import BaseValidator as BaseValidator + +class RegexValidator(BaseValidator): + def __init__(self, pattern: str) -> None: ... + @property + def pattern(self) -> str: ... + def validate(self, input_string: str) -> bool: ... diff --git a/stubs/console-menu/consolemenu/validators/url.pyi b/stubs/console-menu/consolemenu/validators/url.pyi new file mode 100644 index 000000000000..d9e92bb636cc --- /dev/null +++ b/stubs/console-menu/consolemenu/validators/url.pyi @@ -0,0 +1,5 @@ +from consolemenu.validators.base import BaseValidator as BaseValidator + +class UrlValidator(BaseValidator): + def __init__(self) -> None: ... + def validate(self, input_string: str) -> bool: ... diff --git a/stubs/console-menu/consolemenu/version.pyi b/stubs/console-menu/consolemenu/version.pyi new file mode 100644 index 000000000000..e69de29bb2d1 From 9436c993c973203655e86c1b246e74b8f9fffd99 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 1 Oct 2022 17:55:16 +0000 Subject: [PATCH 02/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/console-menu/consolemenu/items/function_item.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/items/function_item.pyi b/stubs/console-menu/consolemenu/items/function_item.pyi index 3fa665cf789f..1d2a76489a35 100644 --- a/stubs/console-menu/consolemenu/items/function_item.pyi +++ b/stubs/console-menu/consolemenu/items/function_item.pyi @@ -1,5 +1,5 @@ -from typing import Any from collections.abc import Callable +from typing import Any from consolemenu.console_menu import ConsoleMenu from consolemenu.items import ExternalItem as ExternalItem From 6ba1038832aada6a5dfebd965902bd058ed16660 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:17:30 -0400 Subject: [PATCH 03/17] Update stubs/console-menu/consolemenu/console_menu.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/console_menu.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi index 916e3e2c7b88..6b89a29dc6b9 100644 --- a/stubs/console-menu/consolemenu/console_menu.pyi +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -34,7 +34,7 @@ class ConsoleMenu: exit_option_text: str = ..., ) -> None: ... @property - def current_item(self) -> MenuItem: ... + def current_item(self) -> MenuItem | None: ... @property def selected_item(self) -> MenuItem: ... def append_item(self, item: MenuItem) -> None: ... From 9d9e9f59470745bdd6d370c97dcc9091f5001115 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:19:54 -0400 Subject: [PATCH 04/17] Update stubs/console-menu/consolemenu/console_menu.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/console_menu.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi index 6b89a29dc6b9..d7edfe3dd396 100644 --- a/stubs/console-menu/consolemenu/console_menu.pyi +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -36,7 +36,7 @@ class ConsoleMenu: @property def current_item(self) -> MenuItem | None: ... @property - def selected_item(self) -> MenuItem: ... + def selected_item(self) -> MenuItem | None: ... def append_item(self, item: MenuItem) -> None: ... def remove_item(self, item: MenuItem) -> bool: ... def add_exit(self) -> bool: ... From 5d78ecf75de7dba61848da19519c5a33cb57f387 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:20:43 -0400 Subject: [PATCH 05/17] Update stubs/console-menu/consolemenu/console_menu.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/console_menu.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi index d7edfe3dd396..4b4abb22c401 100644 --- a/stubs/console-menu/consolemenu/console_menu.pyi +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -66,7 +66,7 @@ class ConsoleMenu: class MenuItem: text: str - menu: ConsoleMenu + menu: ConsoleMenu | None should_exit: bool index_item_separator: str def __init__(self, text: str, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... From 66428d330ba4adc128634fb9759168232c838f84 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:21:18 -0400 Subject: [PATCH 06/17] Update stubs/console-menu/consolemenu/console_menu.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/console_menu.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi index 4b4abb22c401..b5d4d7e3ff5d 100644 --- a/stubs/console-menu/consolemenu/console_menu.pyi +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -80,7 +80,6 @@ class MenuItem: class ExitItem(MenuItem): def __init__(self, text: str = ..., menu: ConsoleMenu | None = ...) -> None: ... - text: str def show(self, index: int, available_width: None = ...): ... def clear_terminal() -> None: ... From f51cc316c3b188057e5424e26ab4191cf62d05e9 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:21:48 -0400 Subject: [PATCH 07/17] Update stubs/console-menu/consolemenu/format/menu_borders.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/format/menu_borders.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/format/menu_borders.pyi b/stubs/console-menu/consolemenu/format/menu_borders.pyi index 21eb4a43f395..fd09bb958444 100644 --- a/stubs/console-menu/consolemenu/format/menu_borders.pyi +++ b/stubs/console-menu/consolemenu/format/menu_borders.pyi @@ -181,7 +181,7 @@ class MenuBorderStyleType: DOUBLE_LINE_OUTER_LIGHT_INNER_BORDER: int class MenuBorderStyleFactory: - logger: Incomplete + logger: logging.Logger def __init__(self) -> None: ... def create_border(self, border_style_type: MenuBorderStyleType): ... def create_ascii_border(self) -> AsciiBorderStyle: ... From 8be7aade34d46e9a39f8774227b579cab0cf2a24 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:22:10 -0400 Subject: [PATCH 08/17] Update stubs/console-menu/consolemenu/format/menu_borders.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/format/menu_borders.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/format/menu_borders.pyi b/stubs/console-menu/consolemenu/format/menu_borders.pyi index fd09bb958444..2af1cc90d9e5 100644 --- a/stubs/console-menu/consolemenu/format/menu_borders.pyi +++ b/stubs/console-menu/consolemenu/format/menu_borders.pyi @@ -183,7 +183,7 @@ class MenuBorderStyleType: class MenuBorderStyleFactory: logger: logging.Logger def __init__(self) -> None: ... - def create_border(self, border_style_type: MenuBorderStyleType): ... + def create_border(self, border_style_type: MenuBorderStyleType) -> MenuBorderStyle: ... def create_ascii_border(self) -> AsciiBorderStyle: ... def create_light_border(self) -> LightBorderStyle: ... def create_heavy_border(self) -> HeavyBorderStyle: ... From 138fa5042946ff62d1fbddc2ec3e4b2f2638b05e Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:22:48 -0400 Subject: [PATCH 09/17] Update stubs/console-menu/consolemenu/items/external_item.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/items/external_item.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/items/external_item.pyi b/stubs/console-menu/consolemenu/items/external_item.pyi index 72ec0187e9b5..ffabfc8b8fc6 100644 --- a/stubs/console-menu/consolemenu/items/external_item.pyi +++ b/stubs/console-menu/consolemenu/items/external_item.pyi @@ -2,6 +2,5 @@ from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem class ExternalItem(MenuItem): - def __init__(self, text: str, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... def set_up(self) -> None: ... def clean_up(self) -> None: ... From 946474dee8a4180aa37bd3147997529f7da5c037 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:23:17 -0400 Subject: [PATCH 10/17] Update stubs/console-menu/consolemenu/items/function_item.pyi Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/items/function_item.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/items/function_item.pyi b/stubs/console-menu/consolemenu/items/function_item.pyi index 1d2a76489a35..382be78c38e5 100644 --- a/stubs/console-menu/consolemenu/items/function_item.pyi +++ b/stubs/console-menu/consolemenu/items/function_item.pyi @@ -12,7 +12,7 @@ class FunctionItem(ExternalItem): def __init__( self, text: str, - function: Callable[[Any], Any], + function: Callable[..., Any], args: list[Any] | None = ..., kwargs: dict[str, Any] | None = ..., menu: ConsoleMenu | None = ..., From 18c345c4b822193ee2418cf19c83832d3ddcbe32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 12:23:29 +0000 Subject: [PATCH 11/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/console-menu/consolemenu/format/menu_borders.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/console-menu/consolemenu/format/menu_borders.pyi b/stubs/console-menu/consolemenu/format/menu_borders.pyi index 2af1cc90d9e5..571ffde8665b 100644 --- a/stubs/console-menu/consolemenu/format/menu_borders.pyi +++ b/stubs/console-menu/consolemenu/format/menu_borders.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - class MenuBorderStyle: @property def bottom_left_corner(self) -> str: ... From c14000a96e0bb8fc0465c21f704dec25da9be26b Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 08:28:31 -0400 Subject: [PATCH 12/17] Apply suggestions from code review Co-authored-by: Jelle Zijlstra --- stubs/console-menu/consolemenu/items/selection_item.pyi | 2 +- stubs/console-menu/consolemenu/menu_formatter.pyi | 2 +- stubs/console-menu/consolemenu/prompt_utils.pyi | 6 +++--- stubs/console-menu/consolemenu/screen.pyi | 4 ++-- stubs/console-menu/consolemenu/selection_menu.pyi | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/stubs/console-menu/consolemenu/items/selection_item.pyi b/stubs/console-menu/consolemenu/items/selection_item.pyi index 423aafbaffd7..3b8d29cf026c 100644 --- a/stubs/console-menu/consolemenu/items/selection_item.pyi +++ b/stubs/console-menu/consolemenu/items/selection_item.pyi @@ -4,6 +4,6 @@ from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem class SelectionItem(MenuItem): - index: Incomplete + index: int def __init__(self, text: str, index: int, menu: ConsoleMenu | None = ...) -> None: ... def get_return(self) -> int: ... diff --git a/stubs/console-menu/consolemenu/menu_formatter.pyi b/stubs/console-menu/consolemenu/menu_formatter.pyi index cfd09a695916..ac10898ebae1 100644 --- a/stubs/console-menu/consolemenu/menu_formatter.pyi +++ b/stubs/console-menu/consolemenu/menu_formatter.pyi @@ -13,7 +13,7 @@ from consolemenu.menu_component import ( class MenuFormatBuilder: def __init__(self, max_dimension: Dimension | None = ...) -> None: ... - def set_border_style(self, border_style: MenuBorderStyle) -> MenuFormatBuilder: ... + def set_border_style(self: Self, border_style: MenuBorderStyle) -> Self: ... def set_border_style_type(self, border_style_type: MenuBorderStyleType) -> MenuFormatBuilder: ... def set_border_style_factory(self, border_style_factory: MenuBorderStyleFactory) -> MenuFormatBuilder: ... def set_bottom_margin(self, bottom_margin: int) -> MenuFormatBuilder: ... diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi index 0366fb514187..ce7ffe850a92 100644 --- a/stubs/console-menu/consolemenu/prompt_utils.pyi +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -34,13 +34,13 @@ class PromptUtils: quit_message: str = ..., ) -> InputResult: ... def input_password(self, message: str | None = ...) -> str: ... - def printf(self, *args: list[Any]) -> None: ... - def println(self, *args: list[Any]) -> None: ... + def printf(self, *args: Any) -> None: ... + def println(self, *args: Any) -> None: ... def prompt_and_confirm_password(self, message: str) -> str: ... def prompt_for_bilateral_choice(self, prompt: str, option1: str, option2: str) -> str: ... def prompt_for_trilateral_choice(self, prompt: str, option1: str, option2: str, option3: str) -> str: ... def prompt_for_yes_or_no(self, prompt: str) -> bool: ... - def prompt_for_numbered_choice(self, choices: list[str], title: str | None = ..., prompt: str = ...) -> int: ... + def prompt_for_numbered_choice(self, choices: Sequence[str], title: str | None = ..., prompt: str = ...) -> int: ... def validate_input(self, input_string: str, validators: BaseValidator) -> bool: ... class UserQuit(Exception): ... diff --git a/stubs/console-menu/consolemenu/screen.pyi b/stubs/console-menu/consolemenu/screen.pyi index 5fc3cd4038bc..68720ce0199b 100644 --- a/stubs/console-menu/consolemenu/screen.pyi +++ b/stubs/console-menu/consolemenu/screen.pyi @@ -12,6 +12,6 @@ class Screen: def flush() -> None: ... def input(self, prompt: str = ...) -> str: ... @staticmethod - def printf(*args: list[Any]) -> None: ... + def printf(*args: Any -> None: ... @staticmethod - def println(*args: list[Any]) -> None: ... + def println(*args: Any) -> None: ... diff --git a/stubs/console-menu/consolemenu/selection_menu.pyi b/stubs/console-menu/consolemenu/selection_menu.pyi index 335b137c00a9..49ff52e4c023 100644 --- a/stubs/console-menu/consolemenu/selection_menu.pyi +++ b/stubs/console-menu/consolemenu/selection_menu.pyi @@ -6,7 +6,7 @@ from consolemenu.screen import Screen class SelectionMenu(ConsoleMenu): def __init__( self, - strings: list[str], + strings: Iterable[str], title: str | None = ..., subtitle: str | None = ..., screen: Screen | None = ..., @@ -20,7 +20,7 @@ class SelectionMenu(ConsoleMenu): @classmethod def get_selection( cls, - strings: list[str], + strings: Iterable[str], title: str = ..., subtitle: str | None = ..., show_exit_option: bool = ..., From 3706e682a2a84cb4b8b6b032fb0ee3cd17ed9ed8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 12:29:43 +0000 Subject: [PATCH 13/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/console-menu/consolemenu/items/external_item.pyi | 1 - stubs/console-menu/consolemenu/items/selection_item.pyi | 2 -- 2 files changed, 3 deletions(-) diff --git a/stubs/console-menu/consolemenu/items/external_item.pyi b/stubs/console-menu/consolemenu/items/external_item.pyi index ffabfc8b8fc6..33cf83a8eb0c 100644 --- a/stubs/console-menu/consolemenu/items/external_item.pyi +++ b/stubs/console-menu/consolemenu/items/external_item.pyi @@ -1,4 +1,3 @@ -from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem class ExternalItem(MenuItem): diff --git a/stubs/console-menu/consolemenu/items/selection_item.pyi b/stubs/console-menu/consolemenu/items/selection_item.pyi index 3b8d29cf026c..b6c098a34437 100644 --- a/stubs/console-menu/consolemenu/items/selection_item.pyi +++ b/stubs/console-menu/consolemenu/items/selection_item.pyi @@ -1,5 +1,3 @@ -from _typeshed import Incomplete - from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem From 33c28bf6017d503c6e262d633572e2726d487680 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 09:07:37 -0400 Subject: [PATCH 14/17] Fix mistakes in initial PR --- .../console-menu/consolemenu/console_menu.pyi | 28 ++++++++++--------- .../consolemenu/format/menu_borders.pyi | 2 ++ .../consolemenu/items/function_item.pyi | 10 +++---- .../consolemenu/items/selection_item.pyi | 4 ++- .../consolemenu/items/submenu_item.pyi | 6 ++-- .../consolemenu/menu_formatter.pyi | 2 +- .../console-menu/consolemenu/prompt_utils.pyi | 3 +- stubs/console-menu/consolemenu/screen.pyi | 2 +- .../consolemenu/selection_menu.pyi | 2 ++ 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/stubs/console-menu/consolemenu/console_menu.pyi b/stubs/console-menu/consolemenu/console_menu.pyi index b5d4d7e3ff5d..aba21b95b1e7 100644 --- a/stubs/console-menu/consolemenu/console_menu.pyi +++ b/stubs/console-menu/consolemenu/console_menu.pyi @@ -1,3 +1,5 @@ +from collections.abc import Callable + from consolemenu.menu_formatter import MenuFormatBuilder as MenuFormatBuilder from consolemenu.screen import Screen as Screen @@ -6,29 +8,29 @@ class ConsoleMenu: screen: Screen clear_screen_before_render: bool formatter: MenuFormatBuilder - title: str | None - subtitle: str | None - prologue_text: str | None - epilogue_text: str | None + title: str | Callable[[], str] | None + subtitle: str | Callable[[], str] | None + prologue_text: str | Callable[[], str] | None + epilogue_text: str | Callable[[], str] | None highlight: None normal: None show_exit_option: bool items: list[MenuItem] - parent: ConsoleMenu + parent: ConsoleMenu | None exit_item: ExitItem current_option: int selected_option: int - returned_value: object + returned_value: object | None should_exit: bool - previous_active_menu: ConsoleMenu + previous_active_menu: ConsoleMenu | None def __init__( self, - title: str | None = ..., - subtitle: str | None = ..., + title: str | Callable[[], str] | None = ..., + subtitle: str | Callable[[], str] | None = ..., screen: Screen | None = ..., formatter: MenuFormatBuilder | None = ..., - prologue_text: str | None = ..., - epilogue_text: str | None = ..., + prologue_text: str | Callable[[], str] | None = ..., + epilogue_text: str | Callable[[], str] | None = ..., clear_screen: bool = ..., show_exit_option: bool = ..., exit_option_text: str = ..., @@ -69,7 +71,7 @@ class MenuItem: menu: ConsoleMenu | None should_exit: bool index_item_separator: str - def __init__(self, text: str, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + def __init__(self, text: str | Callable[[], str], menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... def show(self, index: int) -> str: ... def set_up(self) -> None: ... def action(self) -> None: ... @@ -79,7 +81,7 @@ class MenuItem: def get_text(self) -> str: ... class ExitItem(MenuItem): - def __init__(self, text: str = ..., menu: ConsoleMenu | None = ...) -> None: ... + def __init__(self, text: str | Callable[[], str] = ..., menu: ConsoleMenu | None = ...) -> None: ... def show(self, index: int, available_width: None = ...): ... def clear_terminal() -> None: ... diff --git a/stubs/console-menu/consolemenu/format/menu_borders.pyi b/stubs/console-menu/consolemenu/format/menu_borders.pyi index 571ffde8665b..9710b4abe2be 100644 --- a/stubs/console-menu/consolemenu/format/menu_borders.pyi +++ b/stubs/console-menu/consolemenu/format/menu_borders.pyi @@ -1,3 +1,5 @@ +import logging + class MenuBorderStyle: @property def bottom_left_corner(self) -> str: ... diff --git a/stubs/console-menu/consolemenu/items/function_item.pyi b/stubs/console-menu/consolemenu/items/function_item.pyi index 382be78c38e5..fb6733ed570b 100644 --- a/stubs/console-menu/consolemenu/items/function_item.pyi +++ b/stubs/console-menu/consolemenu/items/function_item.pyi @@ -1,4 +1,4 @@ -from collections.abc import Callable +from collections.abc import Callable, Sequence, Mapping from typing import Any from consolemenu.console_menu import ConsoleMenu @@ -6,15 +6,15 @@ from consolemenu.items import ExternalItem as ExternalItem class FunctionItem(ExternalItem): function: Callable[..., Any] - args: list[Any] - kwargs: dict[str, Any] + args: Sequence[Any] + kwargs: Mapping[str, Any] return_value: Any | None def __init__( self, text: str, function: Callable[..., Any], - args: list[Any] | None = ..., - kwargs: dict[str, Any] | None = ..., + args: Sequence[Any] | None = ..., + kwargs: Mapping[str, Any] | None = ..., menu: ConsoleMenu | None = ..., should_exit: bool = ..., ) -> None: ... diff --git a/stubs/console-menu/consolemenu/items/selection_item.pyi b/stubs/console-menu/consolemenu/items/selection_item.pyi index b6c098a34437..07678800f614 100644 --- a/stubs/console-menu/consolemenu/items/selection_item.pyi +++ b/stubs/console-menu/consolemenu/items/selection_item.pyi @@ -1,7 +1,9 @@ +from collections.abc import Callable + from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem class SelectionItem(MenuItem): index: int - def __init__(self, text: str, index: int, menu: ConsoleMenu | None = ...) -> None: ... + def __init__(self, text: str | Callable[[], str], index: int, menu: ConsoleMenu | None = ...) -> None: ... def get_return(self) -> int: ... diff --git a/stubs/console-menu/consolemenu/items/submenu_item.pyi b/stubs/console-menu/consolemenu/items/submenu_item.pyi index 7a7623ce584f..001d0422fcb0 100644 --- a/stubs/console-menu/consolemenu/items/submenu_item.pyi +++ b/stubs/console-menu/consolemenu/items/submenu_item.pyi @@ -1,13 +1,15 @@ +from collections.abc import Callable + from consolemenu.console_menu import ConsoleMenu from consolemenu.items import MenuItem as MenuItem class SubmenuItem(MenuItem): submenu: ConsoleMenu - def __init__(self, text: str, submenu: ConsoleMenu, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + def __init__(self, text: str | Callable[[], str], submenu: ConsoleMenu, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... menu: ConsoleMenu def set_menu(self, menu: ConsoleMenu) -> None: ... def set_up(self) -> None: ... def action(self) -> None: ... def clean_up(self) -> None: ... - def get_return(self) -> int: ... + def get_return(self) -> object: ... def get_submenu(self) -> ConsoleMenu: ... diff --git a/stubs/console-menu/consolemenu/menu_formatter.pyi b/stubs/console-menu/consolemenu/menu_formatter.pyi index ac10898ebae1..cfd09a695916 100644 --- a/stubs/console-menu/consolemenu/menu_formatter.pyi +++ b/stubs/console-menu/consolemenu/menu_formatter.pyi @@ -13,7 +13,7 @@ from consolemenu.menu_component import ( class MenuFormatBuilder: def __init__(self, max_dimension: Dimension | None = ...) -> None: ... - def set_border_style(self: Self, border_style: MenuBorderStyle) -> Self: ... + def set_border_style(self, border_style: MenuBorderStyle) -> MenuFormatBuilder: ... def set_border_style_type(self, border_style_type: MenuBorderStyleType) -> MenuFormatBuilder: ... def set_border_style_factory(self, border_style_factory: MenuBorderStyleFactory) -> MenuFormatBuilder: ... def set_bottom_margin(self, bottom_margin: int) -> MenuFormatBuilder: ... diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi index ce7ffe850a92..033868343862 100644 --- a/stubs/console-menu/consolemenu/prompt_utils.pyi +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -1,4 +1,5 @@ from typing import Any, NamedTuple +from collections.abc import Iterable, Sequence from consolemenu.screen import Screen from consolemenu.validators.base import BaseValidator as BaseValidator, InvalidValidator as InvalidValidator @@ -28,7 +29,7 @@ class PromptUtils: self, prompt: str | None = ..., default: str | None = ..., - validators: list[BaseValidator] | None = ..., + validators: Iterable[BaseValidator] | None = ..., enable_quit: bool = ..., quit_string: str = ..., quit_message: str = ..., diff --git a/stubs/console-menu/consolemenu/screen.pyi b/stubs/console-menu/consolemenu/screen.pyi index 68720ce0199b..712823c8b81c 100644 --- a/stubs/console-menu/consolemenu/screen.pyi +++ b/stubs/console-menu/consolemenu/screen.pyi @@ -12,6 +12,6 @@ class Screen: def flush() -> None: ... def input(self, prompt: str = ...) -> str: ... @staticmethod - def printf(*args: Any -> None: ... + def printf(*args: Any) -> None: ... @staticmethod def println(*args: Any) -> None: ... diff --git a/stubs/console-menu/consolemenu/selection_menu.pyi b/stubs/console-menu/consolemenu/selection_menu.pyi index 49ff52e4c023..4735cb80e2a5 100644 --- a/stubs/console-menu/consolemenu/selection_menu.pyi +++ b/stubs/console-menu/consolemenu/selection_menu.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from consolemenu import ConsoleMenu as ConsoleMenu from consolemenu.items import SelectionItem as SelectionItem from consolemenu.menu_formatter import MenuFormatBuilder From 72dd2a0102bfe0996e7b0e15009b02344808c1ff Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 13:09:29 +0000 Subject: [PATCH 15/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/console-menu/consolemenu/items/function_item.pyi | 2 +- stubs/console-menu/consolemenu/items/submenu_item.pyi | 4 +++- stubs/console-menu/consolemenu/prompt_utils.pyi | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stubs/console-menu/consolemenu/items/function_item.pyi b/stubs/console-menu/consolemenu/items/function_item.pyi index fb6733ed570b..190778567e42 100644 --- a/stubs/console-menu/consolemenu/items/function_item.pyi +++ b/stubs/console-menu/consolemenu/items/function_item.pyi @@ -1,4 +1,4 @@ -from collections.abc import Callable, Sequence, Mapping +from collections.abc import Callable, Mapping, Sequence from typing import Any from consolemenu.console_menu import ConsoleMenu diff --git a/stubs/console-menu/consolemenu/items/submenu_item.pyi b/stubs/console-menu/consolemenu/items/submenu_item.pyi index 001d0422fcb0..f1d8c611c03d 100644 --- a/stubs/console-menu/consolemenu/items/submenu_item.pyi +++ b/stubs/console-menu/consolemenu/items/submenu_item.pyi @@ -5,7 +5,9 @@ from consolemenu.items import MenuItem as MenuItem class SubmenuItem(MenuItem): submenu: ConsoleMenu - def __init__(self, text: str | Callable[[], str], submenu: ConsoleMenu, menu: ConsoleMenu | None = ..., should_exit: bool = ...) -> None: ... + def __init__( + self, text: str | Callable[[], str], submenu: ConsoleMenu, menu: ConsoleMenu | None = ..., should_exit: bool = ... + ) -> None: ... menu: ConsoleMenu def set_menu(self, menu: ConsoleMenu) -> None: ... def set_up(self) -> None: ... diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi index 033868343862..9bb6c24935e7 100644 --- a/stubs/console-menu/consolemenu/prompt_utils.pyi +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -1,5 +1,5 @@ -from typing import Any, NamedTuple from collections.abc import Iterable, Sequence +from typing import Any, NamedTuple from consolemenu.screen import Screen from consolemenu.validators.base import BaseValidator as BaseValidator, InvalidValidator as InvalidValidator From 4d5dd088351ea7fec526f93f4bc7e337628df0c8 Mon Sep 17 00:00:00 2001 From: Giles Johnson Date: Sun, 2 Oct 2022 11:39:00 -0400 Subject: [PATCH 16/17] Remove re-exports --- stubs/console-menu/consolemenu/prompt_utils.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi index 9bb6c24935e7..bba3020c146b 100644 --- a/stubs/console-menu/consolemenu/prompt_utils.pyi +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable, Sequence from typing import Any, NamedTuple from consolemenu.screen import Screen -from consolemenu.validators.base import BaseValidator as BaseValidator, InvalidValidator as InvalidValidator +from consolemenu.validators.base import BaseValidator, InvalidValidator class InputResult(NamedTuple): input_string: str From 6d756342a0764af23de919ecc816fdfba5789ae3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 2 Oct 2022 15:40:12 +0000 Subject: [PATCH 17/17] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/console-menu/consolemenu/prompt_utils.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/console-menu/consolemenu/prompt_utils.pyi b/stubs/console-menu/consolemenu/prompt_utils.pyi index bba3020c146b..507d716f7c06 100644 --- a/stubs/console-menu/consolemenu/prompt_utils.pyi +++ b/stubs/console-menu/consolemenu/prompt_utils.pyi @@ -2,7 +2,7 @@ from collections.abc import Iterable, Sequence from typing import Any, NamedTuple from consolemenu.screen import Screen -from consolemenu.validators.base import BaseValidator, InvalidValidator +from consolemenu.validators.base import BaseValidator class InputResult(NamedTuple): input_string: str