From 555bf3fac4565553e7401e65b93d878ab23c604e Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:23:10 +0200 Subject: [PATCH 01/10] get rid of Literal types in cget methods --- stdlib/3/tkinter/__init__.pyi | 19 +------------------ stdlib/3/tkinter/ttk.pyi | 18 ------------------ 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 388e523834a1..66ea7ac8234a 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -415,6 +415,7 @@ class Misc: # See #4363 def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... + def cget(self, key: str) -> Any: ... class CallWrapper: func: Any @@ -573,7 +574,6 @@ class Tk(Misc, Wm): @overload def configure(self, cnf: _TkOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _TkOptionName) -> Any: ... def loadtk(self) -> None: ... # differs from _tkinter.TkappType.loadtk def destroy(self) -> None: ... def readprofile(self, baseName: str, className: str) -> None: ... @@ -949,7 +949,6 @@ class Button(Widget): @overload def configure(self, cnf: _ButtonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ButtonOptionName) -> Any: ... def flash(self): ... def invoke(self): ... @@ -1068,7 +1067,6 @@ class Canvas(Widget, XView, YView): @overload def configure(self, cnf: _CanvasOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _CanvasOptionName) -> Any: ... def addtag(self, *args): ... def addtag_above(self, newtag, tagOrId): ... def addtag_all(self, newtag): ... @@ -1296,7 +1294,6 @@ class Checkbutton(Widget): @overload def configure(self, cnf: _CheckbuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _CheckbuttonOptionName) -> Any: ... def deselect(self): ... def flash(self): ... def invoke(self): ... @@ -1434,7 +1431,6 @@ class Entry(Widget, XView): @overload def configure(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _EntryOptionName) -> Any: ... def delete(self, first, last: Optional[Any] = ...): ... def get(self): ... def icursor(self, index): ... @@ -1528,7 +1524,6 @@ class Frame(Widget): @overload def configure(self, cnf: _FrameOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _FrameOptionName) -> Any: ... _LabelOptionName = Literal[ "activebackground", @@ -1643,7 +1638,6 @@ class Label(Widget): @overload def configure(self, cnf: _LabelOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _LabelOptionName) -> Any: ... _ListboxOptionName = Literal[ "activestyle", @@ -1766,7 +1760,6 @@ class Listbox(Widget, XView, YView): @overload def configure(self, cnf: _ListboxOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ListboxOptionName) -> Any: ... def activate(self, index): ... def bbox(self, index): ... def curselection(self): ... @@ -1877,7 +1870,6 @@ class Menu(Widget): @overload def configure(self, cnf: _MenuOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _MenuOptionName) -> Any: ... def tk_popup(self, x, y, entry: str = ...): ... def activate(self, index): ... def add(self, itemType, cnf=..., **kw): ... @@ -2026,7 +2018,6 @@ class Menubutton(Widget): @overload def configure(self, cnf: _MenubuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _MenubuttonOptionName) -> Any: ... _MessageOptionName = Literal[ "anchor", @@ -2115,7 +2106,6 @@ class Message(Widget): @overload def configure(self, cnf: _MessageOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _MessageOptionName) -> Any: ... _RadiobuttonOptionName = Literal[ "activebackground", @@ -2260,7 +2250,6 @@ class Radiobutton(Widget): @overload def configure(self, cnf: _RadiobuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _RadiobuttonOptionName) -> Any: ... def deselect(self): ... def flash(self): ... def invoke(self): ... @@ -2389,7 +2378,6 @@ class Scale(Widget): @overload def configure(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ScaleOptionName) -> Any: ... def get(self): ... def set(self, value): ... def coords(self, value: Optional[Any] = ...): ... @@ -2482,7 +2470,6 @@ class Scrollbar(Widget): @overload def configure(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ScrollbarOptionName) -> Any: ... def activate(self, index: Optional[Any] = ...): ... def delta(self, deltax, deltay): ... def fraction(self, x, y): ... @@ -2650,7 +2637,6 @@ class Text(Widget, XView, YView): @overload def configure(self, cnf: _TextOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _TextOptionName) -> Any: ... def bbox(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int]]: ... def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... def count(self, index1, index2, *args): ... # TODO @@ -3058,7 +3044,6 @@ class Spinbox(Widget, XView): @overload def configure(self, cnf: _SpinboxOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _SpinboxOptionName) -> Any: ... def bbox(self, index): ... def delete(self, first, last: Optional[Any] = ...): ... def get(self): ... @@ -3172,7 +3157,6 @@ class LabelFrame(Widget): @overload def configure(self, cnf: _LabelFrameOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _LabelFrameOptionName) -> Any: ... _PanedWindowOptionName = Literal[ "background", @@ -3257,7 +3241,6 @@ class PanedWindow(Widget): @overload def configure(self, cnf: _PanedWindowOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _PanedWindowOptionName) -> Any: ... def add(self, child, **kw): ... def remove(self, child): ... forget: Any diff --git a/stdlib/3/tkinter/ttk.pyi b/stdlib/3/tkinter/ttk.pyi index 2162373ac244..03d071e70568 100644 --- a/stdlib/3/tkinter/ttk.pyi +++ b/stdlib/3/tkinter/ttk.pyi @@ -93,7 +93,6 @@ class Button(Widget): @overload def configure(self, cnf: _ButtonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ButtonOptionName) -> Any: ... def invoke(self): ... _CheckbuttonOptionName = Literal[ @@ -165,7 +164,6 @@ class Checkbutton(Widget): @overload def configure(self, cnf: _CheckbuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _CheckbuttonOptionName) -> Any: ... def invoke(self): ... _EntryOptionName = Literal[ @@ -262,7 +260,6 @@ class Entry(Widget, tkinter.Entry): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... - def cget(self, key: _EntryOptionName) -> Any: ... # type: ignore def bbox(self, index): ... def identify(self, x, y): ... def validate(self): ... @@ -372,7 +369,6 @@ class Combobox(Entry): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: _ComboboxOptionName) -> Tuple[str, str, str, Any, Any]: ... - def cget(self, key: _ComboboxOptionName) -> Any: ... # type: ignore def current(self, newindex: Optional[Any] = ...): ... def set(self, value): ... @@ -415,7 +411,6 @@ class Frame(Widget): @overload def configure(self, cnf: _FrameOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _FrameOptionName) -> Any: ... _LabelOptionName = Literal[ "anchor", @@ -498,7 +493,6 @@ class Label(Widget): @overload def configure(self, cnf: _LabelOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _LabelOptionName) -> Any: ... _LabelframeOptionName = Literal[ "border", @@ -560,7 +554,6 @@ class Labelframe(Widget): @overload def configure(self, cnf: _LabelframeOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _LabelframeOptionName) -> Any: ... LabelFrame = Labelframe @@ -624,7 +617,6 @@ class Menubutton(Widget): @overload def configure(self, cnf: _MenubuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _MenubuttonOptionName) -> Any: ... _NotebookOptionName = Literal["class", "cursor", "height", "padding", "style", "takefocus", "width"] @@ -657,7 +649,6 @@ class Notebook(Widget): @overload def configure(self, cnf: _NotebookOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _NotebookOptionName) -> Any: ... def add(self, child, **kw): ... def forget(self, tab_id): ... def hide(self, tab_id): ... @@ -713,7 +704,6 @@ class Panedwindow(Widget, tkinter.PanedWindow): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: _PanedwindowOptionName) -> Tuple[str, str, str, Any, Any]: ... - def cget(self, key: _PanedwindowOptionName) -> Any: ... # type: ignore forget: Any def insert(self, pos, child, **kw): ... def pane(self, pane, option: Optional[Any] = ..., **kw): ... @@ -762,7 +752,6 @@ class Progressbar(Widget): @overload def configure(self, cnf: _ProgressbarOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _ProgressbarOptionName) -> Any: ... def start(self, interval: Optional[Any] = ...): ... def step(self, amount: Optional[Any] = ...): ... def stop(self): ... @@ -830,7 +819,6 @@ class Radiobutton(Widget): @overload def configure(self, cnf: _RadiobuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _RadiobuttonOptionName) -> Any: ... def invoke(self): ... _ScaleOptionName = Literal[ @@ -895,7 +883,6 @@ class Scale(Widget, tkinter.Scale): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... - def cget(self, key: _ScaleOptionName) -> Any: ... # type: ignore def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... _ScrollbarOptionName = Literal["class", "command", "cursor", "orient", "style", "takefocus"] @@ -940,7 +927,6 @@ class Scrollbar(Widget, tkinter.Scrollbar): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def config(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... - def cget(self, key: _ScrollbarOptionName) -> Any: ... # type: ignore _SeparatorOptionName = Literal["class", "cursor", "orient", "style", "takefocus"] @@ -969,7 +955,6 @@ class Separator(Widget): @overload def configure(self, cnf: _SeparatorOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _SeparatorOptionName) -> Any: ... _SizegripOptionName = Literal["class", "cursor", "style", "takefocus"] @@ -996,7 +981,6 @@ class Sizegrip(Widget): @overload def configure(self, cnf: _SizegripOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _SizegripOptionName) -> Any: ... if sys.version_info >= (3, 7): _SpinboxOptionName = Literal[ @@ -1088,7 +1072,6 @@ if sys.version_info >= (3, 7): @overload def configure(self, cnf: _SpinboxOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure # type: ignore - def cget(self, key: _SpinboxOptionName) -> Any: ... # type: ignore def set(self, value: Any) -> None: ... _TreeviewOptionName = Literal[ @@ -1149,7 +1132,6 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def configure(self, cnf: _TreeviewOptionName) -> Tuple[str, str, str, Any, Any]: ... config = configure - def cget(self, key: _TreeviewOptionName) -> Any: ... def bbox(self, item, column: Optional[Any] = ...): ... def get_children(self, item: Optional[Any] = ...): ... def set_children(self, item, *newchildren): ... From 3479e228ce7f919c7b943c5aaf5d99449e1ff596 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:27:27 +0200 Subject: [PATCH 02/10] get rid of Literal types in configure methods --- stdlib/3/tkinter/__init__.pyi | 36 +++++++++++++-------------- stdlib/3/tkinter/ttk.pyi | 46 +++++++++++++++++------------------ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 66ea7ac8234a..1e19a6fb1b0f 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -572,7 +572,7 @@ class Tk(Misc, Wm): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _TkOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def loadtk(self) -> None: ... # differs from _tkinter.TkappType.loadtk def destroy(self) -> None: ... @@ -947,7 +947,7 @@ class Button(Widget): wraplength: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ButtonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def flash(self): ... def invoke(self): ... @@ -1065,7 +1065,7 @@ class Canvas(Widget, XView, YView): yscrollincrement: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _CanvasOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def addtag(self, *args): ... def addtag_above(self, newtag, tagOrId): ... @@ -1292,7 +1292,7 @@ class Checkbutton(Widget): wraplength: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _CheckbuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def deselect(self): ... def flash(self): ... @@ -1429,7 +1429,7 @@ class Entry(Widget, XView): xscrollcommand: _XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def delete(self, first, last: Optional[Any] = ...): ... def get(self): ... @@ -1522,7 +1522,7 @@ class Frame(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _FrameOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _LabelOptionName = Literal[ @@ -1636,7 +1636,7 @@ class Label(Widget): wraplength: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _LabelOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _ListboxOptionName = Literal[ @@ -1758,7 +1758,7 @@ class Listbox(Widget, XView, YView): yscrollcommand: _XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ListboxOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def activate(self, index): ... def bbox(self, index): ... @@ -1868,7 +1868,7 @@ class Menu(Widget): type: Literal["menubar", "tearoff", "normal"] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _MenuOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def tk_popup(self, x, y, entry: str = ...): ... def activate(self, index): ... @@ -2016,7 +2016,7 @@ class Menubutton(Widget): wraplength: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _MenubuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _MessageOptionName = Literal[ @@ -2104,7 +2104,7 @@ class Message(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _MessageOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _RadiobuttonOptionName = Literal[ @@ -2248,7 +2248,7 @@ class Radiobutton(Widget): wraplength: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _RadiobuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def deselect(self): ... def flash(self): ... @@ -2376,7 +2376,7 @@ class Scale(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def get(self): ... def set(self, value): ... @@ -2468,7 +2468,7 @@ class Scrollbar(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def activate(self, index: Optional[Any] = ...): ... def delta(self, deltax, deltay): ... @@ -2635,7 +2635,7 @@ class Text(Widget, XView, YView): yscrollcommand: _XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _TextOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, index: _TextIndex) -> Optional[Tuple[int, int, int, int]]: ... def compare(self, index1: _TextIndex, op: Literal["<", "<=", "==", ">=", ">", "!="], index2: _TextIndex) -> bool: ... @@ -3042,7 +3042,7 @@ class Spinbox(Widget, XView): xscrollcommand: _XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _SpinboxOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, index): ... def delete(self, first, last: Optional[Any] = ...): ... @@ -3155,7 +3155,7 @@ class LabelFrame(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _LabelFrameOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _PanedWindowOptionName = Literal[ @@ -3239,7 +3239,7 @@ class PanedWindow(Widget): width: _ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _PanedWindowOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def add(self, child, **kw): ... def remove(self, child): ... diff --git a/stdlib/3/tkinter/ttk.pyi b/stdlib/3/tkinter/ttk.pyi index 03d071e70568..b33d2e405325 100644 --- a/stdlib/3/tkinter/ttk.pyi +++ b/stdlib/3/tkinter/ttk.pyi @@ -91,7 +91,7 @@ class Button(Widget): width: Union[int, Literal[""]] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ButtonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def invoke(self): ... @@ -162,7 +162,7 @@ class Checkbutton(Widget): width: Union[int, Literal[""]] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _CheckbuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def invoke(self): ... @@ -234,7 +234,7 @@ class Entry(Widget, tkinter.Entry): xscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Entry().config is mypy error (don't know why) @overload # type: ignore def config( @@ -259,7 +259,7 @@ class Entry(Widget, tkinter.Entry): xscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def config(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... def bbox(self, index): ... def identify(self, x, y): ... def validate(self): ... @@ -340,7 +340,7 @@ class Combobox(Entry): xscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ComboboxOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Combobox().config is mypy error (don't know why) @overload # type: ignore def config( @@ -368,7 +368,7 @@ class Combobox(Entry): xscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def config(self, cnf: _ComboboxOptionName) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... def current(self, newindex: Optional[Any] = ...): ... def set(self, value): ... @@ -409,7 +409,7 @@ class Frame(Widget): width: tkinter._ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _FrameOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _LabelOptionName = Literal[ @@ -491,7 +491,7 @@ class Label(Widget): wraplength: tkinter._ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _LabelOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _LabelframeOptionName = Literal[ @@ -552,7 +552,7 @@ class Labelframe(Widget): width: tkinter._ScreenUnits = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _LabelframeOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure LabelFrame = Labelframe @@ -615,7 +615,7 @@ class Menubutton(Widget): width: Union[int, Literal[""]] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _MenubuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _NotebookOptionName = Literal["class", "cursor", "height", "padding", "style", "takefocus", "width"] @@ -647,7 +647,7 @@ class Notebook(Widget): width: int = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _NotebookOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def add(self, child, **kw): ... def forget(self, tab_id): ... @@ -689,7 +689,7 @@ class Panedwindow(Widget, tkinter.PanedWindow): width: int = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _PanedwindowOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Panedwindow().config is mypy error (don't know why) @overload # type: ignore def config( @@ -703,7 +703,7 @@ class Panedwindow(Widget, tkinter.PanedWindow): width: int = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def config(self, cnf: _PanedwindowOptionName) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... forget: Any def insert(self, pos, child, **kw): ... def pane(self, pane, option: Optional[Any] = ..., **kw): ... @@ -750,7 +750,7 @@ class Progressbar(Widget): variable: tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ProgressbarOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def start(self, interval: Optional[Any] = ...): ... def step(self, amount: Optional[Any] = ...): ... @@ -817,7 +817,7 @@ class Radiobutton(Widget): width: Union[int, Literal[""]] = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _RadiobuttonOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def invoke(self): ... @@ -862,7 +862,7 @@ class Scale(Widget, tkinter.Scale): variable: tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scale().config is mypy error (don't know why) @overload # type: ignore def config( @@ -882,7 +882,7 @@ class Scale(Widget, tkinter.Scale): variable: tkinter.DoubleVar = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def config(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... _ScrollbarOptionName = Literal["class", "command", "cursor", "orient", "style", "takefocus"] @@ -912,7 +912,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): takefocus: tkinter._TakeFocusValue = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... # config must be copy/pasted, otherwise ttk.Scrollbar().config is mypy error (don't know why) @overload # type: ignore def config( @@ -926,7 +926,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): takefocus: tkinter._TakeFocusValue = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def config(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... + def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... _SeparatorOptionName = Literal["class", "cursor", "orient", "style", "takefocus"] @@ -953,7 +953,7 @@ class Separator(Widget): takefocus: tkinter._TakeFocusValue = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _SeparatorOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure _SizegripOptionName = Literal["class", "cursor", "style", "takefocus"] @@ -979,7 +979,7 @@ class Sizegrip(Widget): takefocus: tkinter._TakeFocusValue = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _SizegripOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure if sys.version_info >= (3, 7): @@ -1070,7 +1070,7 @@ if sys.version_info >= (3, 7): xscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _SpinboxOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure # type: ignore def set(self, value: Any) -> None: ... @@ -1130,7 +1130,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): yscrollcommand: tkinter._XYScrollCommand = ..., ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload - def configure(self, cnf: _TreeviewOptionName) -> Tuple[str, str, str, Any, Any]: ... + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, item, column: Optional[Any] = ...): ... def get_children(self, item: Optional[Any] = ...): ... From 52a659a515e372e8cd283a07a898965385b413a3 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:40:48 +0200 Subject: [PATCH 03/10] get rid of unused _FooOptionName literals --- stdlib/3/tkinter/__init__.pyi | 613 ---------------------------------- stdlib/3/tkinter/ttk.pyi | 218 ------------ 2 files changed, 831 deletions(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 1e19a6fb1b0f..807d4b338a27 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -510,31 +510,6 @@ class Wm: def wm_withdraw(self): ... withdraw: Any -_TkOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "class", - "colormap", - "container", - "cursor", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "menu", - "padx", - "pady", - "relief", - "screen", # can't be changed after creating widget - "takefocus", - "use", - "visual", - "width", -] - class _ExceptionReportingCallback(Protocol): def __call__(self, __exc: Type[BaseException], __val: BaseException, __tb: TracebackType) -> Any: ... @@ -816,45 +791,6 @@ class Toplevel(BaseWidget, Wm): config = Tk.config cget = Tk.cget -_ButtonOptionName = Literal[ - "activebackground", - "activeforeground", - "anchor", - "background", - "bd", # same as borderwidth - "bg", # same as background - "bitmap", - "border", # same as borderwidth - "borderwidth", - "command", - "compound", - "cursor", - "default", - "disabledforeground", - "fg", # same as foreground - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "image", - "justify", - "overrelief", - "padx", - "pady", - "relief", - "repeatdelay", - "repeatinterval", - "state", - "takefocus", - "text", - "textvariable", - "underline", - "width", - "wraplength", -] - class Button(Widget): def __init__( self, @@ -952,39 +888,6 @@ class Button(Widget): def flash(self): ... def invoke(self): ... -_CanvasOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "closeenough", - "confine", - "cursor", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "insertbackground", - "insertborderwidth", - "insertofftime", - "insertontime", - "insertwidth", - "offset", - "relief", - "scrollregion", - "selectbackground", - "selectborderwidth", - "selectforeground", - "state", - "takefocus", - "width", - "xscrollcommand", - "xscrollincrement", - "yscrollcommand", - "yscrollincrement", -] - class Canvas(Widget, XView, YView): def __init__( self, @@ -1138,51 +1041,6 @@ class Canvas(Widget, XView, YView): def select_to(self, tagOrId, index): ... def type(self, tagOrId): ... -_CheckbuttonOptionName = Literal[ - "activebackground", - "activeforeground", - "anchor", - "background", - "bd", - "bg", - "bitmap", - "border", - "borderwidth", - "command", - "compound", - "cursor", - "disabledforeground", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "image", - "indicatoron", - "justify", - "offrelief", - "offvalue", - "onvalue", - "overrelief", - "padx", - "pady", - "relief", - "selectcolor", - "selectimage", - "state", - "takefocus", - "text", - "textvariable", - "tristateimage", - "tristatevalue", - "underline", - "variable", - "width", - "wraplength", -] - class Checkbutton(Widget): def __init__( self, @@ -1300,46 +1158,6 @@ class Checkbutton(Widget): def select(self): ... def toggle(self): ... -_EntryOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "cursor", - "disabledbackground", - "disabledforeground", - "exportselection", - "fg", - "font", - "foreground", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "insertbackground", - "insertborderwidth", - "insertofftime", - "insertontime", - "insertwidth", - "invalidcommand", - "invcmd", # same as invalidcommand - "justify", - "readonlybackground", - "relief", - "selectbackground", - "selectborderwidth", - "selectforeground", - "show", - "state", - "takefocus", - "textvariable", - "validate", - "validatecommand", - "vcmd", # same as validatecommand - "width", - "xscrollcommand", -] - class Entry(Widget, XView): def __init__( self, @@ -1451,28 +1269,6 @@ class Entry(Widget, XView): def selection_to(self, index): ... select_to: Any -_FrameOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "class", - "colormap", - "container", - "cursor", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "padx", - "pady", - "relief", - "takefocus", - "visual", - "width", -] - class Frame(Widget): def __init__( self, @@ -1525,40 +1321,6 @@ class Frame(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_LabelOptionName = Literal[ - "activebackground", - "activeforeground", - "anchor", - "background", - "bd", - "bg", - "bitmap", - "border", - "borderwidth", - "compound", - "cursor", - "disabledforeground", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "image", - "justify", - "padx", - "pady", - "relief", - "state", - "takefocus", - "text", - "textvariable", - "underline", - "width", - "wraplength", -] - class Label(Widget): def __init__( self, @@ -1639,38 +1401,6 @@ class Label(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_ListboxOptionName = Literal[ - "activestyle", - "background", - "bd", - "bg", - "border", - "borderwidth", - "cursor", - "disabledforeground", - "exportselection", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "justify", - "listvariable", - "relief", - "selectbackground", - "selectborderwidth", - "selectforeground", - "selectmode", - "setgrid", - "state", - "takefocus", - "width", - "xscrollcommand", - "yscrollcommand", -] - class Listbox(Widget, XView, YView): def __init__( self, @@ -1784,30 +1514,6 @@ class Listbox(Widget, XView, YView): def itemconfigure(self, index, cnf: Optional[Any] = ..., **kw): ... itemconfig: Any -_MenuOptionName = Literal[ - "activebackground", - "activeborderwidth", - "activeforeground", - "background", - "bd", - "bg", - "border", - "borderwidth", - "cursor", - "disabledforeground", - "fg", - "font", - "foreground", - "postcommand", - "relief", - "selectcolor", - "takefocus", - "tearoff", - "tearoffcommand", - "title", - "type", -] - class Menu(Widget): def __init__( self, @@ -1896,43 +1602,6 @@ class Menu(Widget): def xposition(self, index): ... def yposition(self, index): ... -_MenubuttonOptionName = Literal[ - "activebackground", - "activeforeground", - "anchor", - "background", - "bd", - "bg", - "bitmap", - "border", - "borderwidth", - "compound", - "cursor", - "direction", - "disabledforeground", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "image", - "indicatoron", - "justify", - "menu", - "padx", - "pady", - "relief", - "state", - "takefocus", - "text", - "textvariable", - "underline", - "width", - "wraplength", -] - class Menubutton(Widget): def __init__( self, @@ -2019,31 +1688,6 @@ class Menubutton(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_MessageOptionName = Literal[ - "anchor", - "aspect", - "background", - "bd", - "bg", - "border", - "borderwidth", - "cursor", - "fg", - "font", - "foreground", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "justify", - "padx", - "pady", - "relief", - "takefocus", - "text", - "textvariable", - "width", -] - class Message(Widget): def __init__( self, @@ -2107,50 +1751,6 @@ class Message(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_RadiobuttonOptionName = Literal[ - "activebackground", - "activeforeground", - "anchor", - "background", - "bd", - "bg", - "bitmap", - "border", - "borderwidth", - "command", - "compound", - "cursor", - "disabledforeground", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "image", - "indicatoron", - "justify", - "offrelief", - "overrelief", - "padx", - "pady", - "relief", - "selectcolor", - "selectimage", - "state", - "takefocus", - "text", - "textvariable", - "tristateimage", - "tristatevalue", - "underline", - "value", - "variable", - "width", - "wraplength", -] - class Radiobutton(Widget): def __init__( self, @@ -2255,43 +1855,6 @@ class Radiobutton(Widget): def invoke(self): ... def select(self): ... -_ScaleOptionName = Literal[ - "activebackground", - "background", - "bd", - "bg", - "bigincrement", - "border", - "borderwidth", - "command", - "cursor", - "digits", - "fg", - "font", - "foreground", - "from", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "label", - "length", - "orient", - "relief", - "repeatdelay", - "repeatinterval", - "resolution", - "showvalue", - "sliderlength", - "sliderrelief", - "state", - "takefocus", - "tickinterval", - "to", - "troughcolor", - "variable", - "width", -] - class Scale(Widget): def __init__( self, @@ -2383,30 +1946,6 @@ class Scale(Widget): def coords(self, value: Optional[Any] = ...): ... def identify(self, x, y): ... -_ScrollbarOptionName = Literal[ - "activebackground", - "activerelief", - "background", - "bd", - "bg", - "border", - "borderwidth", - "command", - "cursor", - "elementborderwidth", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "jump", - "orient", - "relief", - "repeatdelay", - "repeatinterval", - "takefocus", - "troughcolor", - "width", -] - class Scrollbar(Widget): def __init__( self, @@ -2478,53 +2017,6 @@ class Scrollbar(Widget): def set(self, first, last): ... _TextIndex = Union[_tkinter.Tcl_Obj, str, float] -_TextOptionName = Literal[ - "autoseparators", - "background", - "bd", - "bg", - "blockcursor", - "border", - "borderwidth", - "cursor", - "endline", - "exportselection", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "inactiveselectbackground", - "insertbackground", - "insertborderwidth", - "insertofftime", - "insertontime", - "insertunfocussed", - "insertwidth", - "maxundo", - "padx", - "pady", - "relief", - "selectbackground", - "selectborderwidth", - "selectforeground", - "setgrid", - "spacing1", - "spacing2", - "spacing3", - "startline", - "state", - "tabs", - "tabstyle", - "takefocus", - "undo", - "width", - "wrap", - "xscrollcommand", - "yscrollcommand", -] class Text(Widget, XView, YView): def __init__( @@ -2873,59 +2365,6 @@ class BitmapImage(Image): def image_names(): ... def image_types(): ... -_SpinboxOptionName = Literal[ - "activebackground", - "background", - "bd", - "bg", - "border", - "borderwidth", - "buttonbackground", - "buttoncursor", - "buttondownrelief", - "buttonuprelief", - "command", - "cursor", - "disabledbackground", - "disabledforeground", - "exportselection", - "fg", - "font", - "foreground", - "format", - "from", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "increment", - "insertbackground", - "insertborderwidth", - "insertofftime", - "insertontime", - "insertwidth", - "invalidcommand", - "invcmd", - "justify", - "readonlybackground", - "relief", - "repeatdelay", - "repeatinterval", - "selectbackground", - "selectborderwidth", - "selectforeground", - "state", - "takefocus", - "textvariable", - "to", - "validate", - "validatecommand", - "vcmd", - "values", - "width", - "wrap", - "xscrollcommand", -] - class Spinbox(Widget, XView): def __init__( self, @@ -3065,34 +2504,6 @@ class Spinbox(Widget, XView): def selection_range(self, start: int, end: int) -> None: ... def selection_to(self, index: int) -> None: ... -_LabelFrameOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "class", - "colormap", - "container", - "cursor", - "fg", - "font", - "foreground", - "height", - "highlightbackground", - "highlightcolor", - "highlightthickness", - "labelanchor", - "labelwidget", - "padx", - "pady", - "relief", - "takefocus", - "text", - "visual", - "width", -] - class LabelFrame(Widget): def __init__( self, @@ -3158,30 +2569,6 @@ class LabelFrame(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_PanedWindowOptionName = Literal[ - "background", - "bd", - "bg", - "border", - "borderwidth", - "cursor", - "handlepad", - "handlesize", - "height", - "opaqueresize", - "orient", - "proxybackground", - "proxyborderwidth", - "proxyrelief", - "relief", - "sashcursor", - "sashpad", - "sashrelief", - "sashwidth", - "showhandle", - "width", -] - class PanedWindow(Widget): def __init__( self, diff --git a/stdlib/3/tkinter/ttk.pyi b/stdlib/3/tkinter/ttk.pyi index b33d2e405325..4af90d7cb9d0 100644 --- a/stdlib/3/tkinter/ttk.pyi +++ b/stdlib/3/tkinter/ttk.pyi @@ -33,23 +33,6 @@ class Widget(tkinter.Widget): def instate(self, statespec, callback: Optional[Any] = ..., *args, **kw): ... def state(self, statespec: Optional[Any] = ...): ... -_ButtonOptionName = Literal[ - "class", - "command", - "compound", - "cursor", - "default", - "image", - "padding", - "state", - "style", - "takefocus", - "text", - "textvariable", - "underline", - "width", -] - class Button(Widget): def __init__( self, @@ -95,25 +78,6 @@ class Button(Widget): config = configure def invoke(self): ... -_CheckbuttonOptionName = Literal[ - "class", - "command", - "compound", - "cursor", - "image", - "offvalue", - "onvalue", - "padding", - "state", - "style", - "takefocus", - "text", - "textvariable", - "underline", - "variable", - "width", -] - class Checkbutton(Widget): def __init__( self, @@ -166,26 +130,6 @@ class Checkbutton(Widget): config = configure def invoke(self): ... -_EntryOptionName = Literal[ - "background", - "class", - "cursor", - "exportselection", - "font", - "foreground", - "invalidcommand", - "justify", - "show", - "state", - "style", - "takefocus", - "textvariable", - "validate", - "validatecommand", - "width", - "xscrollcommand", -] - class Entry(Widget, tkinter.Entry): def __init__( self, @@ -264,29 +208,6 @@ class Entry(Widget, tkinter.Entry): def identify(self, x, y): ... def validate(self): ... -_ComboboxOptionName = Literal[ - "background", - "class", - "cursor", - "exportselection", - "font", - "foreground", - "height", - "invalidcommand", - "justify", - "postcommand", - "show", - "state", - "style", - "takefocus", - "textvariable", - "validate", - "validatecommand", - "values", - "width", - "xscrollcommand", -] - class Combobox(Entry): def __init__( self, @@ -372,10 +293,6 @@ class Combobox(Entry): def current(self, newindex: Optional[Any] = ...): ... def set(self, value): ... -_FrameOptionName = Literal[ - "border", "borderwidth", "class", "cursor", "height", "padding", "relief", "style", "takefocus", "width" -] - class Frame(Widget): def __init__( self, @@ -412,30 +329,6 @@ class Frame(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_LabelOptionName = Literal[ - "anchor", - "background", - "border", - "borderwidth", - "class", - "compound", - "cursor", - "font", - "foreground", - "image", - "justify", - "padding", - "relief", - "state", - "style", - "takefocus", - "text", - "textvariable", - "underline", - "width", - "wraplength", -] - class Label(Widget): def __init__( self, @@ -494,23 +387,6 @@ class Label(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_LabelframeOptionName = Literal[ - "border", - "borderwidth", - "class", - "cursor", - "height", - "labelanchor", - "labelwidget", - "padding", - "relief", - "style", - "takefocus", - "text", - "underline", - "width", -] - class Labelframe(Widget): def __init__( self, @@ -557,23 +433,6 @@ class Labelframe(Widget): LabelFrame = Labelframe -_MenubuttonOptionName = Literal[ - "class", - "compound", - "cursor", - "direction", - "image", - "menu", - "padding", - "state", - "style", - "takefocus", - "text", - "textvariable", - "underline", - "width", -] - class Menubutton(Widget): def __init__( self, @@ -618,8 +477,6 @@ class Menubutton(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_NotebookOptionName = Literal["class", "cursor", "height", "padding", "style", "takefocus", "width"] - class Notebook(Widget): def __init__( self, @@ -660,8 +517,6 @@ class Notebook(Widget): def tabs(self): ... def enable_traversal(self): ... -_PanedwindowOptionName = Literal["class", "cursor", "height", "orient", "style", "takefocus", "width"] - class Panedwindow(Widget, tkinter.PanedWindow): def __init__( self, @@ -711,10 +566,6 @@ class Panedwindow(Widget, tkinter.PanedWindow): PanedWindow = Panedwindow -_ProgressbarOptionName = Literal[ - "class", "cursor", "length", "maximum", "mode", "orient", "phase", "style", "takefocus", "value", "variable" -] - class Progressbar(Widget): def __init__( self, @@ -756,24 +607,6 @@ class Progressbar(Widget): def step(self, amount: Optional[Any] = ...): ... def stop(self): ... -_RadiobuttonOptionName = Literal[ - "class", - "command", - "compound", - "cursor", - "image", - "padding", - "state", - "style", - "takefocus", - "text", - "textvariable", - "underline", - "value", - "variable", - "width", -] - class Radiobutton(Widget): def __init__( self, @@ -821,10 +654,6 @@ class Radiobutton(Widget): config = configure def invoke(self): ... -_ScaleOptionName = Literal[ - "class", "command", "cursor", "from", "length", "orient", "state", "style", "takefocus", "to", "value", "variable" -] - class Scale(Widget, tkinter.Scale): def __init__( self, @@ -885,8 +714,6 @@ class Scale(Widget, tkinter.Scale): def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... -_ScrollbarOptionName = Literal["class", "command", "cursor", "orient", "style", "takefocus"] - class Scrollbar(Widget, tkinter.Scrollbar): def __init__( self, @@ -928,8 +755,6 @@ class Scrollbar(Widget, tkinter.Scrollbar): @overload def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... -_SeparatorOptionName = Literal["class", "cursor", "orient", "style", "takefocus"] - class Separator(Widget): def __init__( self, @@ -956,8 +781,6 @@ class Separator(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure -_SizegripOptionName = Literal["class", "cursor", "style", "takefocus"] - class Sizegrip(Widget): def __init__( self, @@ -983,32 +806,6 @@ class Sizegrip(Widget): config = configure if sys.version_info >= (3, 7): - _SpinboxOptionName = Literal[ - "background", - "class", - "command", - "cursor", - "exportselection", - "font", - "foreground", - "format", - "from", - "increment", - "invalidcommand", - "justify", - "show", - "state", - "style", - "takefocus", - "textvariable", - "to", - "validate", - "validatecommand", - "values", - "width", - "wrap", - "xscrollcommand", - ] class Spinbox(Entry): def __init__( self, @@ -1074,21 +871,6 @@ if sys.version_info >= (3, 7): config = configure # type: ignore def set(self, value: Any) -> None: ... -_TreeviewOptionName = Literal[ - "class", - "columns", - "cursor", - "displaycolumns", - "height", - "padding", - "selectmode", - "show", - "style", - "takefocus", - "xscrollcommand", - "yscrollcommand", -] - class Treeview(Widget, tkinter.XView, tkinter.YView): def __init__( self, From de56b819dd30a97f0585f1c18071449b0d4881e3 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:43:28 +0200 Subject: [PATCH 04/10] remove now-unnecessary aliasing --- stdlib/3/tkinter/__init__.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 807d4b338a27..d93b3c4fa1dd 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -789,7 +789,6 @@ class Toplevel(BaseWidget, Wm): # Tcl/Tk toplevel widget. configure = Tk.configure config = Tk.config - cget = Tk.cget class Button(Widget): def __init__( From 08435bd1d8aa53e3a216ac5bc400a12cfe81ad94 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:48:14 +0200 Subject: [PATCH 05/10] add configure method to Misc --- stdlib/3/tkinter/__init__.pyi | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index d93b3c4fa1dd..1e559ef8d2df 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -416,6 +416,8 @@ class Misc: def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... def cget(self, key: str) -> Any: ... + def configure(self, key: str) -> Any: ... + # TODO: config is an alias of configure, but adding that here creates lots of mypy errors class CallWrapper: func: Any @@ -526,7 +528,7 @@ class Tk(Misc, Wm): ) -> None: ... @overload def configure( - self: Union[Tk, Toplevel], + self, cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., @@ -757,6 +759,9 @@ class Widget(BaseWidget, Pack, Place, Grid): def bind(self, *, func: str, add: Optional[bool] = ...) -> None: ... class Toplevel(BaseWidget, Wm): + # Toplevel and Tk have the same options because they correspond to the same + # Tcl/Tk toplevel widget. For some reason, config and configure must be + # copy/pasted here instead of aliasing as 'config = Tk.config'. def __init__( self, master: Optional[Misc] = ..., @@ -785,10 +790,31 @@ class Toplevel(BaseWidget, Wm): visual: Union[str, Tuple[str, int]] = ..., width: _ScreenUnits = ..., ) -> None: ... - # Toplevel and Tk have the same options because they correspond to the same - # Tcl/Tk toplevel widget. - configure = Tk.configure - config = Tk.config + @overload + def configure( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + background: _Color = ..., + bd: _ScreenUnits = ..., + bg: _Color = ..., + border: _ScreenUnits = ..., + borderwidth: _ScreenUnits = ..., + cursor: _Cursor = ..., + height: _ScreenUnits = ..., + highlightbackground: _Color = ..., + highlightcolor: _Color = ..., + highlightthickness: _ScreenUnits = ..., + menu: Menu = ..., + padx: _ScreenUnits = ..., + pady: _ScreenUnits = ..., + relief: _Relief = ..., + takefocus: _TakeFocusValue = ..., + width: _ScreenUnits = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... + config = configure class Button(Widget): def __init__( From 0239870094e16559b8ac3ce564c14b8146ff8f64 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:54:49 +0200 Subject: [PATCH 06/10] add pr number to comment --- stdlib/3/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 1e559ef8d2df..e1c077e69a1d 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -412,7 +412,7 @@ class Misc: def event_info(self, virtual: Optional[Any] = ...): ... def image_names(self): ... def image_types(self): ... - # See #4363 + # See #4363 and #4891 def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... def cget(self, key: str) -> Any: ... From 2d4bbf648bf39337968868eac99fb3e8e8c220e6 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 14:57:26 +0200 Subject: [PATCH 07/10] fix argument name --- stdlib/3/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index e1c077e69a1d..8812656ffef0 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -416,7 +416,7 @@ class Misc: def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... def cget(self, key: str) -> Any: ... - def configure(self, key: str) -> Any: ... + def configure(self, cnf: str) -> Any: ... # TODO: config is an alias of configure, but adding that here creates lots of mypy errors class CallWrapper: From 36adfc1ca80994910ba9b3734b3ae8304a846852 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 15:01:26 +0200 Subject: [PATCH 08/10] try to fix stubtest warning with Any and default --- stdlib/3/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 8812656ffef0..a0338230eca9 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -416,7 +416,7 @@ class Misc: def __setitem__(self, key: str, value: Any) -> None: ... def __getitem__(self, key: str) -> Any: ... def cget(self, key: str) -> Any: ... - def configure(self, cnf: str) -> Any: ... + def configure(self, cnf: Any = ...) -> Any: ... # TODO: config is an alias of configure, but adding that here creates lots of mypy errors class CallWrapper: From e7df50993e1ac626e1b99382261bf907570ff431 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 15:33:38 +0200 Subject: [PATCH 09/10] add back deleted comments --- stdlib/3/tkinter/__init__.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index a0338230eca9..afc700e03fff 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -826,17 +826,17 @@ class Button(Widget): activeforeground: _Color = ..., anchor: _Anchor = ..., background: _Color = ..., - bd: _ScreenUnits = ..., - bg: _Color = ..., + bd: _ScreenUnits = ..., # same as borderwidth + bg: _Color = ..., # same as background bitmap: _Bitmap = ..., - border: _ScreenUnits = ..., + border: _ScreenUnits = ..., # same as borderwidth borderwidth: _ScreenUnits = ..., command: _ButtonCommand = ..., compound: _Compound = ..., cursor: _Cursor = ..., default: Literal["normal", "active", "disabled"] = ..., disabledforeground: _Color = ..., - fg: _Color = ..., + fg: _Color = ..., # same as foreground font: _FontDescription = ..., foreground: _Color = ..., # width and height must be int for buttons containing just text, but @@ -1210,7 +1210,7 @@ class Entry(Widget, XView): insertontime: int = ..., insertwidth: _ScreenUnits = ..., invalidcommand: _EntryValidateCommand = ..., - invcmd: _EntryValidateCommand = ..., + invcmd: _EntryValidateCommand = ..., # same as invalidcommand justify: Literal["left", "center", "right"] = ..., name: str = ..., readonlybackground: _Color = ..., @@ -1224,7 +1224,7 @@ class Entry(Widget, XView): textvariable: Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., validatecommand: _EntryValidateCommand = ..., - vcmd: _EntryValidateCommand = ..., + vcmd: _EntryValidateCommand = ..., # same as validatecommand width: int = ..., xscrollcommand: _XYScrollCommand = ..., ) -> None: ... From 4d398130d0f54bd132a1e7c0a6e958b695e57118 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sat, 2 Jan 2021 15:38:01 +0200 Subject: [PATCH 10/10] add back one more deleted comment --- stdlib/3/tkinter/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index afc700e03fff..c2a1c5b20a76 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -784,7 +784,7 @@ class Toplevel(BaseWidget, Wm): padx: _ScreenUnits = ..., pady: _ScreenUnits = ..., relief: _Relief = ..., - screen: str = ..., + screen: str = ..., # can't be changed after creating widget takefocus: _TakeFocusValue = ..., use: int = ..., visual: Union[str, Tuple[str, int]] = ...,