Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type stubs for package console-menu. #8820

Merged
merged 18 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7ff61b6
Add type stubs for package console-menu.
bastisawesome Oct 1, 2022
9436c99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 1, 2022
99c79d9
Merge branch 'python:master' into master
bastisawesome Oct 2, 2022
6ba1038
Update stubs/console-menu/consolemenu/console_menu.pyi
bastisawesome Oct 2, 2022
9d9e9f5
Update stubs/console-menu/consolemenu/console_menu.pyi
bastisawesome Oct 2, 2022
5d78ecf
Update stubs/console-menu/consolemenu/console_menu.pyi
bastisawesome Oct 2, 2022
66428d3
Update stubs/console-menu/consolemenu/console_menu.pyi
bastisawesome Oct 2, 2022
f51cc31
Update stubs/console-menu/consolemenu/format/menu_borders.pyi
bastisawesome Oct 2, 2022
8be7aad
Update stubs/console-menu/consolemenu/format/menu_borders.pyi
bastisawesome Oct 2, 2022
138fa50
Update stubs/console-menu/consolemenu/items/external_item.pyi
bastisawesome Oct 2, 2022
946474d
Update stubs/console-menu/consolemenu/items/function_item.pyi
bastisawesome Oct 2, 2022
18c345c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2022
c14000a
Apply suggestions from code review
bastisawesome Oct 2, 2022
3706e68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2022
33c28bf
Fix mistakes in initial PR
bastisawesome Oct 2, 2022
72dd2a0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2022
4d5dd08
Remove re-exports
bastisawesome Oct 2, 2022
6d75634
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"stubs/caldav",
"stubs/cffi",
"stubs/commonmark",
"stubs/console-menu",
"stubs/cryptography",
"stubs/dateparser",
"stubs/dj-database-url",
Expand Down
4 changes: 4 additions & 0 deletions stubs/console-menu/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version = "0.7.*"

[tool.stubtest]
ignore_missing_stub = false
6 changes: 6 additions & 0 deletions stubs/console-menu/consolemenu/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
87 changes: 87 additions & 0 deletions stubs/console-menu/consolemenu/console_menu.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from collections.abc import Callable

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 | 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 | None
exit_item: ExitItem
current_option: int
selected_option: int
returned_value: object | None
should_exit: bool
previous_active_menu: ConsoleMenu | None
def __init__(
self,
title: str | Callable[[], str] | None = ...,
subtitle: str | Callable[[], str] | None = ...,
screen: Screen | None = ...,
formatter: MenuFormatBuilder | None = ...,
prologue_text: str | Callable[[], str] | None = ...,
epilogue_text: str | Callable[[], str] | None = ...,
clear_screen: bool = ...,
show_exit_option: bool = ...,
exit_option_text: str = ...,
) -> None: ...
@property
def current_item(self) -> MenuItem | None: ...
@property
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: ...
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 | None
should_exit: bool
index_item_separator: str
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: ...
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 | Callable[[], str] = ..., menu: ConsoleMenu | None = ...) -> None: ...
def show(self, index: int, available_width: None = ...): ...

def clear_terminal() -> None: ...
14 changes: 14 additions & 0 deletions stubs/console-menu/consolemenu/format/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
194 changes: 194 additions & 0 deletions stubs/console-menu/consolemenu/format/menu_borders.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import logging

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: logging.Logger
def __init__(self) -> None: ...
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: ...
bastisawesome marked this conversation as resolved.
Show resolved Hide resolved
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: ...
18 changes: 18 additions & 0 deletions stubs/console-menu/consolemenu/format/menu_margins.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
18 changes: 18 additions & 0 deletions stubs/console-menu/consolemenu/format/menu_padding.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
29 changes: 29 additions & 0 deletions stubs/console-menu/consolemenu/format/menu_style.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
6 changes: 6 additions & 0 deletions stubs/console-menu/consolemenu/items/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
Loading