From 8f77471d621f4c81b14209a086f81a37acb62cdc Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 8 Jun 2022 16:23:54 +0800 Subject: [PATCH] `tkinter`: remove unnecessary `_MenuIndex` TypeAlias (#8023) --- stdlib/tkinter/__init__.pyi | 58 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index f3e7d719b..187ea5ca2 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -2197,32 +2197,30 @@ class Listbox(Widget, XView, YView): @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure - def activate(self, index: int | str) -> None: ... - def bbox(self, index: int | str) -> tuple[int, int, int, int] | None: ... # type: ignore[override] + def activate(self, index: str | int) -> None: ... + def bbox(self, index: str | int) -> tuple[int, int, int, int] | None: ... # type: ignore[override] def curselection(self): ... - def delete(self, first: int | str, last: int | str | None = ...) -> None: ... - def get(self, first: int | str, last: int | str | None = ...): ... - def index(self, index: int | str) -> int: ... - def insert(self, index: int | str, *elements: str | float) -> None: ... + def delete(self, first: str | int, last: str | int | None = ...) -> None: ... + def get(self, first: str | int, last: str | int | None = ...): ... + def index(self, index: str | int) -> int: ... + def insert(self, index: str | int, *elements: str | float) -> None: ... def nearest(self, y): ... def scan_mark(self, x, y) -> None: ... def scan_dragto(self, x, y) -> None: ... - def see(self, index: int | str) -> None: ... - def selection_anchor(self, index: int | str) -> None: ... + def see(self, index: str | int) -> None: ... + def selection_anchor(self, index: str | int) -> None: ... select_anchor = selection_anchor - def selection_clear(self, first: int | str, last: int | str | None = ...) -> None: ... # type: ignore[override] + def selection_clear(self, first: str | int, last: str | int | None = ...) -> None: ... # type: ignore[override] select_clear = selection_clear - def selection_includes(self, index: int | str): ... + def selection_includes(self, index: str | int): ... select_includes = selection_includes - def selection_set(self, first: int | str, last: int | str | None = ...) -> None: ... + def selection_set(self, first: str | int, last: str | int | None = ...) -> None: ... select_set = selection_set def size(self) -> int: ... # type: ignore[override] - def itemcget(self, index: int | str, option): ... - def itemconfigure(self, index: int | str, cnf: Any | None = ..., **kw): ... + def itemcget(self, index: str | int, option): ... + def itemconfigure(self, index: str | int, cnf: Any | None = ..., **kw): ... itemconfig = itemconfigure -_MenuIndex: TypeAlias = str | int - class Menu(Widget): def __init__( self, @@ -2285,8 +2283,8 @@ class Menu(Widget): @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure - def tk_popup(self, x: int, y: int, entry: _MenuIndex = ...) -> None: ... - def activate(self, index: _MenuIndex) -> None: ... + def tk_popup(self, x: int, y: int, entry: str | int = ...) -> None: ... + def activate(self, index: str | int) -> None: ... def add(self, itemType, cnf=..., **kw): ... # docstring says "Internal function." def insert(self, index, itemType, cnf=..., **kw): ... # docstring says "Internal function." def add_cascade( @@ -2384,7 +2382,7 @@ class Menu(Widget): def add_separator(self, cnf: dict[str, Any] | None = ..., *, background: _Color = ...) -> None: ... def insert_cascade( self, - index: _MenuIndex, + index: str | int, cnf: dict[str, Any] | None = ..., *, accelerator: str = ..., @@ -2406,7 +2404,7 @@ class Menu(Widget): ) -> None: ... def insert_checkbutton( self, - index: _MenuIndex, + index: str | int, cnf: dict[str, Any] | None = ..., *, accelerator: str = ..., @@ -2433,7 +2431,7 @@ class Menu(Widget): ) -> None: ... def insert_command( self, - index: _MenuIndex, + index: str | int, cnf: dict[str, Any] | None = ..., *, accelerator: str = ..., @@ -2454,7 +2452,7 @@ class Menu(Widget): ) -> None: ... def insert_radiobutton( self, - index: _MenuIndex, + index: str | int, cnf: dict[str, Any] | None = ..., *, accelerator: str = ..., @@ -2478,20 +2476,20 @@ class Menu(Widget): value: Any = ..., variable: Variable = ..., ) -> None: ... - def insert_separator(self, index: _MenuIndex, cnf: dict[str, Any] | None = ..., *, background: _Color = ...) -> None: ... - def delete(self, index1: _MenuIndex, index2: _MenuIndex | None = ...) -> None: ... - def entrycget(self, index: _MenuIndex, option: str) -> Any: ... + def insert_separator(self, index: str | int, cnf: dict[str, Any] | None = ..., *, background: _Color = ...) -> None: ... + def delete(self, index1: str | int, index2: str | int | None = ...) -> None: ... + def entrycget(self, index: str | int, option: str) -> Any: ... def entryconfigure( - self, index: _MenuIndex, cnf: dict[str, Any] | None = ..., **kw: Any + self, index: str | int, cnf: dict[str, Any] | None = ..., **kw: Any ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... entryconfig = entryconfigure - def index(self, index: _MenuIndex) -> int | None: ... - def invoke(self, index: _MenuIndex) -> Any: ... + def index(self, index: str | int) -> int | None: ... + def invoke(self, index: str | int) -> Any: ... def post(self, x: int, y: int) -> None: ... - def type(self, index: _MenuIndex) -> Literal["cascade", "checkbutton", "command", "radiobutton", "separator"]: ... + def type(self, index: str | int) -> Literal["cascade", "checkbutton", "command", "radiobutton", "separator"]: ... def unpost(self) -> None: ... - def xposition(self, index: _MenuIndex) -> int: ... - def yposition(self, index: _MenuIndex) -> int: ... + def xposition(self, index: str | int) -> int: ... + def yposition(self, index: str | int) -> int: ... class Menubutton(Widget): def __init__(