From 5e5f3b4ecc33ea8ee80a5a307e8358fcba4a202e Mon Sep 17 00:00:00 2001 From: Akuli Date: Tue, 2 Aug 2022 22:10:25 +0300 Subject: [PATCH] Use typeshed.Incomplete and object instead of Any in tkinter stubs (#8458) Co-authored-by: Alex Waygood --- pyrightconfig.stricter.json | 4 + stdlib/tkinter/__init__.pyi | 165 ++++++++++++++++---------------- stdlib/tkinter/colorchooser.pyi | 4 +- stdlib/tkinter/commondialog.pyi | 11 ++- stdlib/tkinter/dialog.pyi | 3 +- stdlib/tkinter/filedialog.pyi | 28 +++--- stdlib/tkinter/messagebox.pyi | 18 ++-- stdlib/tkinter/scrolledtext.pyi | 3 +- stdlib/tkinter/tix.pyi | 121 +++++++++++------------ stdlib/tkinter/ttk.pyi | 91 +++++++++--------- 10 files changed, 230 insertions(+), 218 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index cfc6dc594..798b9e9c9 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -13,10 +13,14 @@ "stdlib/sqlite3/dbapi2.pyi", "stdlib/_tkinter.pyi", "stdlib/tkinter/__init__.pyi", + "stdlib/tkinter/colorchooser.pyi", "stdlib/tkinter/commondialog.pyi", "stdlib/tkinter/dialog.pyi", "stdlib/tkinter/dnd.pyi", "stdlib/tkinter/filedialog.pyi", + "stdlib/tkinter/messagebox.pyi", + "stdlib/tkinter/scrolledtext.pyi", + "stdlib/tkinter/tix.pyi", "stdlib/tkinter/ttk.pyi", "stdlib/xml/dom/NodeFilter.pyi", "stdlib/xml/dom/expatbuilder.pyi", diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 0955992d2..7a0dcb4a0 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1,6 +1,6 @@ import _tkinter import sys -from _typeshed import StrOrBytesPath +from _typeshed import Incomplete, StrOrBytesPath from collections.abc import Callable, Mapping, Sequence from enum import Enum from tkinter.constants import * @@ -195,7 +195,8 @@ _Padding: TypeAlias = Union[ ] _Relief: TypeAlias = Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] # manual page: Tk_GetRelief _ScreenUnits: TypeAlias = str | float # Often the right type instead of int. Manual page: Tk_GetPixels -_XYScrollCommand: TypeAlias = str | Callable[[float, float], Any] # -xscrollcommand and -yscrollcommand in 'options' manual page +# -xscrollcommand and -yscrollcommand in 'options' manual page +_XYScrollCommand: TypeAlias = str | Callable[[float, float], object] _TakeFocusValue: TypeAlias = Union[int, Literal[""], Callable[[str], bool | None]] # -takefocus in manual page named 'options' if sys.version_info >= (3, 11): @@ -277,11 +278,11 @@ def NoDefaultRoot() -> None: ... _TraceMode: TypeAlias = Literal["array", "read", "write", "unset"] class Variable: - def __init__(self, master: Misc | None = ..., value: Any | None = ..., name: str | None = ...) -> None: ... - def set(self, value: Any) -> None: ... + def __init__(self, master: Misc | None = ..., value: Incomplete | None = ..., name: str | None = ...) -> None: ... + def set(self, value) -> None: ... initialize = set - def get(self) -> Any: ... - def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], Any]) -> str: ... + def get(self): ... + def trace_add(self, mode: _TraceMode, callback: Callable[[str, str, str], object]) -> str: ... def trace_remove(self, mode: _TraceMode, cbname: str) -> None: ... def trace_info(self) -> list[tuple[tuple[_TraceMode, ...], str]]: ... def trace_variable(self, mode, callback): ... # deprecated @@ -316,8 +317,8 @@ class BooleanVar(Variable): def mainloop(n: int = ...) -> None: ... -getint: Any -getdouble: Any +getint: Incomplete +getdouble: Incomplete def getboolean(s): ... @@ -333,7 +334,7 @@ class Misc: children: dict[str, Widget] def destroy(self) -> None: ... def deletecommand(self, name: str) -> None: ... - def tk_strictMotif(self, boolean: Any | None = ...): ... + def tk_strictMotif(self, boolean: Incomplete | None = ...): ... def tk_bisque(self) -> None: ... def tk_setPalette(self, *args, **kw) -> None: ... def wait_variable(self, name: str | Variable = ...) -> None: ... @@ -357,9 +358,9 @@ class Misc: @overload def after(self, ms: int, func: None = ...) -> None: ... @overload - def after(self, ms: int | Literal["idle"], func: Callable[..., Any], *args: Any) -> str: ... + def after(self, ms: int | Literal["idle"], func: Callable[..., object], *args: Any) -> str: ... # after_idle is essentially partialmethod(after, "idle") - def after_idle(self, func: Callable[..., Any], *args: Any) -> str: ... + def after_idle(self, func: Callable[..., object], *args: Any) -> str: ... def after_cancel(self, id: str) -> None: ... def bell(self, displayof: Literal[0] | Misc | None = ...) -> None: ... def clipboard_get(self, *, displayof: Misc = ..., type: str = ...) -> str: ... @@ -375,15 +376,15 @@ class Misc: ) -> None: ... def option_clear(self) -> None: ... def option_get(self, name, className): ... - def option_readfile(self, fileName, priority: Any | None = ...) -> None: ... + def option_readfile(self, fileName, priority: Incomplete | None = ...) -> None: ... def selection_clear(self, **kw) -> None: ... def selection_get(self, **kw): ... def selection_handle(self, command, **kw) -> None: ... def selection_own(self, **kw) -> None: ... def selection_own_get(self, **kw): ... def send(self, interp, cmd, *args): ... - def lower(self, belowThis: Any | None = ...) -> None: ... - def tkraise(self, aboveThis: Any | None = ...) -> None: ... + def lower(self, belowThis: Incomplete | None = ...) -> None: ... + def tkraise(self, aboveThis: Incomplete | None = ...) -> None: ... lift = tkraise if sys.version_info >= (3, 11): def info_patchlevel(self) -> _VersionInfoType: ... @@ -449,7 +450,7 @@ class Misc: def bind( self, sequence: str | None = ..., - func: Callable[[Event[Misc]], Any] | None = ..., + func: Callable[[Event[Misc]], object] | None = ..., add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload @@ -462,7 +463,7 @@ class Misc: def bind_all( self, sequence: str | None = ..., - func: Callable[[Event[Misc]], Any] | None = ..., + func: Callable[[Event[Misc]], object] | None = ..., add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload @@ -474,7 +475,7 @@ class Misc: self, className: str, sequence: str | None = ..., - func: Callable[[Event[Misc]], Any] | None = ..., + func: Callable[[Event[Misc]], object] | None = ..., add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload @@ -490,7 +491,7 @@ class Misc: def _windowingsystem(self) -> Literal["win32", "aqua", "x11"]: ... def nametowidget(self, name: str | Misc | _tkinter.Tcl_Obj) -> Any: ... def register( - self, func: Callable[..., Any], subst: Callable[..., Sequence[Any]] | None = ..., needcleanup: int = ... + self, func: Callable[..., object], subst: Callable[..., Sequence[Any]] | None = ..., needcleanup: int = ... ) -> str: ... def keys(self) -> list[str]: ... @overload @@ -588,9 +589,9 @@ class Misc: # TODO: config is an alias of configure, but adding that here creates lots of mypy errors class CallWrapper: - func: Any - subst: Any - widget: Any + func: Incomplete + subst: Incomplete + widget: Incomplete def __init__(self, func, subst, widget) -> None: ... def __call__(self, *args): ... @@ -598,7 +599,7 @@ class XView: @overload def xview(self) -> tuple[float, float]: ... @overload - def xview(self, *args: Any) -> Any: ... + def xview(self, *args): ... def xview_moveto(self, fraction: float) -> None: ... @overload def xview_scroll(self, number: int, what: Literal["units", "pages"]) -> None: ... @@ -609,7 +610,7 @@ class YView: @overload def yview(self) -> tuple[float, float]: ... @overload - def yview(self, *args: Any) -> Any: ... + def yview(self, *args): ... def yview_moveto(self, fraction: float) -> None: ... @overload def yview_scroll(self, number: int, what: Literal["units", "pages"]) -> None: ... @@ -627,9 +628,9 @@ class Wm: @overload def wm_attributes(self) -> tuple[Any, ...]: ... @overload - def wm_attributes(self, __option: str) -> Any: ... + def wm_attributes(self, __option: str): ... @overload - def wm_attributes(self, __option: str, __value: Any, *__other_option_value_pairs: Any) -> None: ... + def wm_attributes(self, __option: str, __value, *__other_option_value_pairs: Any) -> None: ... attributes = wm_attributes def wm_client(self, name: str | None = ...) -> str: ... client = wm_client @@ -657,24 +658,28 @@ class Wm: def wm_geometry(self, newGeometry: str) -> None: ... geometry = wm_geometry def wm_grid( - self, baseWidth: Any | None = ..., baseHeight: Any | None = ..., widthInc: Any | None = ..., heightInc: Any | None = ... + self, + baseWidth: Incomplete | None = ..., + baseHeight: Incomplete | None = ..., + widthInc: Incomplete | None = ..., + heightInc: Incomplete | None = ..., ): ... grid = wm_grid - def wm_group(self, pathName: Any | None = ...): ... + def wm_group(self, pathName: Incomplete | None = ...): ... group = wm_group - def wm_iconbitmap(self, bitmap: Any | None = ..., default: Any | None = ...): ... + def wm_iconbitmap(self, bitmap: Incomplete | None = ..., default: Incomplete | None = ...): ... iconbitmap = wm_iconbitmap def wm_iconify(self) -> None: ... iconify = wm_iconify - def wm_iconmask(self, bitmap: Any | None = ...): ... + def wm_iconmask(self, bitmap: Incomplete | None = ...): ... iconmask = wm_iconmask - def wm_iconname(self, newName: Any | None = ...) -> str: ... + def wm_iconname(self, newName: Incomplete | None = ...) -> str: ... iconname = wm_iconname def wm_iconphoto(self, default: bool, __image1: Image, *args: Image) -> None: ... iconphoto = wm_iconphoto def wm_iconposition(self, x: int | None = ..., y: int | None = ...) -> tuple[int, int] | None: ... iconposition = wm_iconposition - def wm_iconwindow(self, pathName: Any | None = ...): ... + def wm_iconwindow(self, pathName: Incomplete | None = ...): ... iconwindow = wm_iconwindow def wm_manage(self, widget) -> None: ... manage = wm_manage @@ -696,7 +701,7 @@ class Wm: def wm_positionfrom(self, who: Literal["program", "user"] | None = ...) -> Literal["", "program", "user"]: ... positionfrom = wm_positionfrom @overload - def wm_protocol(self, name: str, func: Callable[[], Any] | str) -> None: ... + def wm_protocol(self, name: str, func: Callable[[], object] | str) -> None: ... @overload def wm_protocol(self, name: str, func: None = ...) -> str: ... @overload @@ -728,7 +733,7 @@ class Wm: withdraw = wm_withdraw class _ExceptionReportingCallback(Protocol): - def __call__(self, __exc: type[BaseException], __val: BaseException, __tb: TracebackType | None) -> Any: ... + def __call__(self, __exc: type[BaseException], __val: BaseException, __tb: TracebackType | None) -> object: ... class Tk(Misc, Wm): master: None @@ -923,7 +928,7 @@ class Grid: class BaseWidget(Misc): master: Misc - widgetName: Any + widgetName: Incomplete def __init__(self, master, widgetName, cnf=..., kw=..., extra=...) -> None: ... def destroy(self) -> None: ... @@ -936,7 +941,7 @@ class Widget(BaseWidget, Pack, Place, Grid): def bind( self: _W, sequence: str | None = ..., - func: Callable[[Event[_W]], Any] | None = ..., + func: Callable[[Event[_W]], object] | None = ..., add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload @@ -1126,7 +1131,7 @@ class Canvas(Widget, XView, YView): insertontime: int = ..., insertwidth: _ScreenUnits = ..., name: str = ..., - offset: Any = ..., # undocumented + offset: Incomplete = ..., # undocumented relief: _Relief = ..., # Setting scrollregion to None doesn't reset it back to empty, # but setting it to () does. @@ -1165,7 +1170,7 @@ class Canvas(Widget, XView, YView): insertofftime: int = ..., insertontime: int = ..., insertwidth: _ScreenUnits = ..., - offset: Any = ..., # undocumented + offset: Incomplete = ..., # undocumented relief: _Relief = ..., scrollregion: tuple[_ScreenUnits, _ScreenUnits, _ScreenUnits, _ScreenUnits] | tuple[()] = ..., selectbackground: _Color = ..., @@ -1216,7 +1221,7 @@ class Canvas(Widget, XView, YView): self, tagOrId: str | _CanvasItemId, sequence: str | None = ..., - func: Callable[[Event[Canvas]], Any] | None = ..., + func: Callable[[Event[Canvas]], object] | None = ..., add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload @@ -1226,8 +1231,8 @@ class Canvas(Widget, XView, YView): @overload def tag_bind(self, tagOrId: str | _CanvasItemId, *, func: str, add: Literal["", "+"] | bool | None = ...) -> None: ... def tag_unbind(self, tagOrId: str | _CanvasItemId, sequence: str, funcid: str | None = ...) -> None: ... - def canvasx(self, screenx, gridspacing: Any | None = ...): ... - def canvasy(self, screeny, gridspacing: Any | None = ...): ... + def canvasx(self, screenx, gridspacing: Incomplete | None = ...): ... + def canvasy(self, screeny, gridspacing: Incomplete | None = ...): ... @overload def coords(self, __tagOrId: str | _CanvasItemId) -> list[float]: ... @overload @@ -2218,7 +2223,7 @@ class Listbox(Widget, XView, YView): select_set = selection_set def size(self) -> int: ... # type: ignore[override] def itemcget(self, index: str | int, option): ... - def itemconfigure(self, index: str | int, cnf: Any | None = ..., **kw): ... + def itemconfigure(self, index: str | int, cnf: Incomplete | None = ..., **kw): ... itemconfig = itemconfigure class Menu(Widget): @@ -2241,7 +2246,7 @@ class Menu(Widget): font: _FontDescription = ..., foreground: _Color = ..., name: str = ..., - postcommand: Callable[[], Any] | str = ..., + postcommand: Callable[[], object] | str = ..., relief: _Relief = ..., selectcolor: _Color = ..., takefocus: _TakeFocusValue = ..., @@ -2249,7 +2254,7 @@ class Menu(Widget): # I guess tearoffcommand arguments are supposed to be widget objects, # but they are widget name strings. Use nametowidget() to handle the # arguments of tearoffcommand. - tearoffcommand: Callable[[str, str], Any] | str = ..., + tearoffcommand: Callable[[str, str], object] | str = ..., title: str = ..., type: Literal["menubar", "tearoff", "normal"] = ..., ) -> None: ... @@ -2271,12 +2276,12 @@ class Menu(Widget): fg: _Color = ..., font: _FontDescription = ..., foreground: _Color = ..., - postcommand: Callable[[], Any] | str = ..., + postcommand: Callable[[], object] | str = ..., relief: _Relief = ..., selectcolor: _Color = ..., takefocus: _TakeFocusValue = ..., tearoff: bool = ..., - tearoffcommand: Callable[[str, str], Any] | str = ..., + tearoffcommand: Callable[[str, str], object] | str = ..., title: str = ..., type: Literal["menubar", "tearoff", "normal"] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -2297,7 +2302,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2318,7 +2323,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2344,7 +2349,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2364,7 +2369,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2391,7 +2396,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2413,7 +2418,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2440,7 +2445,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2461,7 +2466,7 @@ class Menu(Widget): background: _Color = ..., bitmap: _Bitmap = ..., columnbreak: int = ..., - command: Callable[[], Any] | str = ..., + command: Callable[[], object] | str = ..., compound: _Compound = ..., font: _FontDescription = ..., foreground: _Color = ..., @@ -2758,7 +2763,7 @@ class Scale(Widget): border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., # don't know why the callback gets string instead of float - command: str | Callable[[str], Any] = ..., + command: str | Callable[[str], object] = ..., cursor: _Cursor = ..., digits: int = ..., fg: _Color = ..., @@ -2799,7 +2804,7 @@ class Scale(Widget): bigincrement: float = ..., border: _ScreenUnits = ..., borderwidth: _ScreenUnits = ..., - command: str | Callable[[str], Any] = ..., + command: str | Callable[[str], object] = ..., cursor: _Cursor = ..., digits: int = ..., fg: _Color = ..., @@ -2898,7 +2903,7 @@ class Scrollbar(Widget): @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure - def activate(self, index: Any | None = ...): ... + def activate(self, index: Incomplete | None = ...): ... def delta(self, deltax: int, deltay: int) -> float: ... def fraction(self, x: int, y: int) -> float: ... def identify(self, x: int, y: int) -> Literal["arrow1", "arrow2", "slider", "trough1", "trough2", ""]: ... @@ -3046,7 +3051,7 @@ class Text(Widget, XView, YView): self, index1: _TextIndex, index2: _TextIndex | None, - command: Callable[[str, str, str], Any] | str, + command: Callable[[str, str, str], object] | str, *, all: bool = ..., image: bool = ..., @@ -3061,7 +3066,7 @@ class Text(Widget, XView, YView): index1: _TextIndex, index2: _TextIndex | None = ..., *, - command: Callable[[str, str, str], Any] | str, + command: Callable[[str, str, str], object] | str, all: bool = ..., image: bool = ..., mark: bool = ..., @@ -3081,7 +3086,7 @@ class Text(Widget, XView, YView): def get(self, index1: _TextIndex, index2: _TextIndex | None = ...) -> str: ... # TODO: image_* methods def image_cget(self, index, option): ... - def image_configure(self, index, cnf: Any | None = ..., **kw): ... + def image_configure(self, index, cnf: Incomplete | None = ..., **kw): ... def image_create(self, index, cnf=..., **kw): ... def image_names(self): ... def index(self, index: _TextIndex) -> str: ... @@ -3096,7 +3101,7 @@ class Text(Widget, XView, YView): def mark_next(self, index: _TextIndex) -> str | None: ... def mark_previous(self, index: _TextIndex) -> str | None: ... # **kw of peer_create is same as the kwargs of Text.__init__ - def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw) -> None: ... def peer_names(self) -> tuple[_tkinter.Tcl_Obj, ...]: ... def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ... def scan_mark(self, x: int, y: int) -> None: ... @@ -3122,14 +3127,14 @@ class Text(Widget, XView, YView): self, tagName: str, sequence: str | None, - func: Callable[[Event[Text]], Any] | None, + func: Callable[[Event[Text]], object] | None, add: Literal["", "+"] | bool | None = ..., ) -> str: ... @overload def tag_bind(self, tagName: str, sequence: str | None, func: str, add: Literal["", "+"] | bool | None = ...) -> None: ... def tag_unbind(self, tagName: str, sequence: str, funcid: str | None = ...) -> None: ... # allowing any string for cget instead of just Literals because there's no other way to look up tag options - def tag_cget(self, tagName: str, option: str) -> Any: ... + def tag_cget(self, tagName: str, option: str): ... @overload def tag_configure( self, @@ -3179,20 +3184,20 @@ class Text(Widget, XView, YView): def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = ...) -> None: ... # TODO: window_* methods def window_cget(self, index, option): ... - def window_configure(self, index, cnf: Any | None = ..., **kw): ... + def window_configure(self, index, cnf: Incomplete | None = ..., **kw): ... window_config = window_configure def window_create(self, index, cnf=..., **kw) -> None: ... def window_names(self): ... def yview_pickplace(self, *what): ... # deprecated class _setit: - def __init__(self, var, value, callback: Any | None = ...) -> None: ... + def __init__(self, var, value, callback: Incomplete | None = ...) -> None: ... def __call__(self, *args) -> None: ... # manual page: tk_optionMenu class OptionMenu(Menubutton): - widgetName: Any - menuname: Any + widgetName: Incomplete + menuname: Incomplete def __init__( # differs from other widgets self, @@ -3201,7 +3206,7 @@ class OptionMenu(Menubutton): value: str, *values: str, # kwarg only from now on - command: Callable[[StringVar], Any] | None = ..., + command: Callable[[StringVar], object] | None = ..., ) -> None: ... # configure, config, cget are inherited from Menubutton # destroy and __getitem__ are overridden, signature does not change @@ -3212,16 +3217,16 @@ class _Image(Protocol): def width(self) -> int: ... class Image: - name: Any + name: Incomplete tk: _tkinter.TkappType def __init__( - self, imgtype, name: Any | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw + self, imgtype, name: Incomplete | None = ..., cnf=..., master: Misc | _tkinter.TkappType | None = ..., **kw ) -> None: ... def __del__(self) -> None: ... def __setitem__(self, key, value) -> None: ... def __getitem__(self, key): ... - configure: Any - config: Any + configure: Incomplete + config: Incomplete def height(self) -> int: ... def type(self): ... def width(self) -> int: ... @@ -3281,7 +3286,7 @@ class PhotoImage(Image): class BitmapImage(Image): def __init__( self, - name: Any | None = ..., + name: Incomplete | None = ..., cnf: dict[str, Any] = ..., master: Misc | _tkinter.TkappType | None = ..., *, @@ -3313,7 +3318,7 @@ class Spinbox(Widget, XView): buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., # percent substitutions don't seem to be supported, it's similar to Entry's validation stuff - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3370,7 +3375,7 @@ class Spinbox(Widget, XView): buttoncursor: _Cursor = ..., buttondownrelief: _Relief = ..., buttonuprelief: _Relief = ..., - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., cursor: _Cursor = ..., disabledbackground: _Color = ..., disabledforeground: _Color = ..., @@ -3415,7 +3420,7 @@ class Spinbox(Widget, XView): def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... config = configure def bbox(self, index) -> tuple[int, int, int, int] | None: ... # type: ignore[override] - def delete(self, first, last: Any | None = ...) -> Literal[""]: ... + def delete(self, first, last: Incomplete | None = ...) -> Literal[""]: ... def get(self) -> str: ... def icursor(self, index): ... def identify(self, x: int, y: int) -> Literal["", "buttondown", "buttonup", "entry"]: ... @@ -3426,10 +3431,10 @@ class Spinbox(Widget, XView): def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... - def selection(self, *args: Any) -> tuple[int, ...]: ... + def selection(self, *args) -> tuple[int, ...]: ... def selection_adjust(self, index): ... def selection_clear(self): ... - def selection_element(self, element: Any | None = ...): ... + def selection_element(self, element: Incomplete | None = ...): ... if sys.version_info >= (3, 8): def selection_from(self, index: int) -> None: ... def selection_present(self) -> None: ... @@ -3562,7 +3567,7 @@ class PanedWindow(Widget): config = configure def add(self, child: Widget, **kw) -> None: ... def remove(self, child) -> None: ... - forget: Any + forget: Incomplete def identify(self, x: int, y: int): ... def proxy(self, *args): ... def proxy_coord(self): ... @@ -3573,8 +3578,8 @@ class PanedWindow(Widget): def sash_mark(self, index): ... def sash_place(self, index, x, y): ... def panecget(self, child, option): ... - def paneconfigure(self, tagOrId, cnf: Any | None = ..., **kw): ... - paneconfig: Any + def paneconfigure(self, tagOrId, cnf: Incomplete | None = ..., **kw): ... + paneconfig: Incomplete def panes(self): ... def _test() -> None: ... diff --git a/stdlib/tkinter/colorchooser.pyi b/stdlib/tkinter/colorchooser.pyi index e0473afa5..ac2ea187b 100644 --- a/stdlib/tkinter/colorchooser.pyi +++ b/stdlib/tkinter/colorchooser.pyi @@ -1,6 +1,6 @@ import sys from tkinter.commondialog import Dialog -from typing import Any, ClassVar +from typing import ClassVar if sys.version_info >= (3, 9): __all__ = ["Chooser", "askcolor"] @@ -8,4 +8,4 @@ if sys.version_info >= (3, 9): class Chooser(Dialog): command: ClassVar[str] -def askcolor(color: str | bytes | None = ..., **options: Any) -> tuple[None, None] | tuple[tuple[float, float, float], str]: ... +def askcolor(color: str | bytes | None = ..., **options) -> tuple[None, None] | tuple[tuple[float, float, float], str]: ... diff --git a/stdlib/tkinter/commondialog.pyi b/stdlib/tkinter/commondialog.pyi index faebcc339..49101c7e6 100644 --- a/stdlib/tkinter/commondialog.pyi +++ b/stdlib/tkinter/commondialog.pyi @@ -1,13 +1,14 @@ import sys +from _typeshed import Incomplete from collections.abc import Mapping -from typing import Any, ClassVar +from typing import ClassVar if sys.version_info >= (3, 9): __all__ = ["Dialog"] class Dialog: command: ClassVar[str | None] - master: Any | None - options: Mapping[str, Any] - def __init__(self, master: Any | None = ..., **options) -> None: ... - def show(self, **options) -> Any: ... + master: Incomplete | None + options: Mapping[str, Incomplete] + def __init__(self, master: Incomplete | None = ..., **options) -> None: ... + def show(self, **options): ... diff --git a/stdlib/tkinter/dialog.pyi b/stdlib/tkinter/dialog.pyi index 9ced7a208..ef7713f40 100644 --- a/stdlib/tkinter/dialog.pyi +++ b/stdlib/tkinter/dialog.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Incomplete from collections.abc import Mapping from tkinter import Widget from typing import Any @@ -11,5 +12,5 @@ DIALOG_ICON: str class Dialog(Widget): widgetName: str num: int - def __init__(self, master: Any | None = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ... + def __init__(self, master: Incomplete | None = ..., cnf: Mapping[str, Any] = ..., **kw) -> None: ... def destroy(self) -> None: ... diff --git a/stdlib/tkinter/filedialog.pyi b/stdlib/tkinter/filedialog.pyi index 2815289e8..cc9e4c8dc 100644 --- a/stdlib/tkinter/filedialog.pyi +++ b/stdlib/tkinter/filedialog.pyi @@ -1,8 +1,8 @@ import sys -from _typeshed import StrOrBytesPath +from _typeshed import Incomplete, StrOrBytesPath from collections.abc import Iterable from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog -from typing import IO, Any, ClassVar +from typing import IO, ClassVar from typing_extensions import Literal if sys.version_info >= (3, 9): @@ -22,12 +22,12 @@ if sys.version_info >= (3, 9): "askdirectory", ] -dialogstates: dict[Any, tuple[Any, Any]] +dialogstates: dict[Incomplete, tuple[Incomplete, Incomplete]] class FileDialog: title: str - master: Any - directory: Any | None + master: Incomplete + directory: Incomplete | None top: Toplevel botframe: Frame selection: Entry @@ -41,21 +41,21 @@ class FileDialog: filter_button: Button cancel_button: Button def __init__( - self, master, title: Any | None = ... + self, master, title: Incomplete | None = ... ) -> None: ... # title is usually a str or None, but e.g. int doesn't raise en exception either - how: Any | None - def go(self, dir_or_file: Any = ..., pattern: str = ..., default: str = ..., key: Any | None = ...): ... - def quit(self, how: Any | None = ...) -> None: ... + how: Incomplete | None + def go(self, dir_or_file: Incomplete = ..., pattern: str = ..., default: str = ..., key: Incomplete | None = ...): ... + def quit(self, how: Incomplete | None = ...) -> None: ... def dirs_double_event(self, event) -> None: ... def dirs_select_event(self, event) -> None: ... def files_double_event(self, event) -> None: ... def files_select_event(self, event) -> None: ... def ok_event(self, event) -> None: ... def ok_command(self) -> None: ... - def filter_command(self, event: Any | None = ...) -> None: ... + def filter_command(self, event: Incomplete | None = ...) -> None: ... def get_filter(self): ... def get_selection(self): ... - def cancel_command(self, event: Any | None = ...) -> None: ... + def cancel_command(self, event: Incomplete | None = ...) -> None: ... def set_filter(self, dir, pat) -> None: ... def set_selection(self, file) -> None: ... @@ -126,7 +126,7 @@ def asksaveasfile( parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> IO[Any] | None: ... +) -> IO[Incomplete] | None: ... def askopenfile( mode: str = ..., *, @@ -137,7 +137,7 @@ def askopenfile( parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> IO[Any] | None: ... +) -> IO[Incomplete] | None: ... def askopenfiles( mode: str = ..., *, @@ -148,5 +148,5 @@ def askopenfiles( parent: Misc | None = ..., title: str | None = ..., typevariable: StringVar | str | None = ..., -) -> tuple[IO[Any], ...]: ... # can be empty tuple +) -> tuple[IO[Incomplete], ...]: ... # can be empty tuple def test() -> None: ... diff --git a/stdlib/tkinter/messagebox.pyi b/stdlib/tkinter/messagebox.pyi index 96109b116..d99c588e3 100644 --- a/stdlib/tkinter/messagebox.pyi +++ b/stdlib/tkinter/messagebox.pyi @@ -1,6 +1,6 @@ import sys from tkinter.commondialog import Dialog -from typing import Any, ClassVar +from typing import ClassVar if sys.version_info >= (3, 9): __all__ = [ @@ -34,11 +34,11 @@ NO: str class Message(Dialog): command: ClassVar[str] -def showinfo(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... -def showwarning(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... -def showerror(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... -def askquestion(title: str | None = ..., message: str | None = ..., **options: Any) -> str: ... -def askokcancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... -def askyesno(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... -def askyesnocancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool | None: ... -def askretrycancel(title: str | None = ..., message: str | None = ..., **options: Any) -> bool: ... +def showinfo(title: str | None = ..., message: str | None = ..., **options) -> str: ... +def showwarning(title: str | None = ..., message: str | None = ..., **options) -> str: ... +def showerror(title: str | None = ..., message: str | None = ..., **options) -> str: ... +def askquestion(title: str | None = ..., message: str | None = ..., **options) -> str: ... +def askokcancel(title: str | None = ..., message: str | None = ..., **options) -> bool: ... +def askyesno(title: str | None = ..., message: str | None = ..., **options) -> bool: ... +def askyesnocancel(title: str | None = ..., message: str | None = ..., **options) -> bool | None: ... +def askretrycancel(title: str | None = ..., message: str | None = ..., **options) -> bool: ... diff --git a/stdlib/tkinter/scrolledtext.pyi b/stdlib/tkinter/scrolledtext.pyi index 00309431d..72f6ca8c0 100644 --- a/stdlib/tkinter/scrolledtext.pyi +++ b/stdlib/tkinter/scrolledtext.pyi @@ -1,5 +1,4 @@ from tkinter import Frame, Misc, Scrollbar, Text -from typing import Any __all__ = ["ScrolledText"] @@ -7,4 +6,4 @@ __all__ = ["ScrolledText"] class ScrolledText(Text): frame: Frame vbar: Scrollbar - def __init__(self, master: Misc | None = ..., **kwargs: Any) -> None: ... + def __init__(self, master: Misc | None = ..., **kwargs) -> None: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 6f9201a1b..db568bc4a 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,4 +1,5 @@ import tkinter +from _typeshed import Incomplete from typing import Any from typing_extensions import Literal @@ -56,12 +57,12 @@ class TixWidget(tkinter.Widget): cnf: dict[str, Any] = ..., kw: dict[str, Any] = ..., ) -> None: ... - def __getattr__(self, name: str) -> Any: ... + def __getattr__(self, name: str): ... def set_silent(self, value: str) -> None: ... def subwidget(self, name: str) -> tkinter.Widget: ... def subwidgets_all(self) -> list[tkinter.Widget]: ... def config_all(self, option: Any, value: Any) -> None: ... - def image_create(self, imgtype: str, cnf: dict[str, Any] = ..., master: tkinter.Widget | None = ..., **kw: Any) -> None: ... + def image_create(self, imgtype: str, cnf: dict[str, Any] = ..., master: tkinter.Widget | None = ..., **kw) -> None: ... def image_delete(self, imgname: str) -> None: ... class TixSubWidget(TixWidget): @@ -70,102 +71,102 @@ class TixSubWidget(TixWidget): ) -> None: ... class DisplayStyle: - def __init__(self, itemtype: str, cnf: dict[str, Any] = ..., *, master: tkinter.Widget | None = ..., **kw: Any) -> None: ... - def __getitem__(self, key: str) -> Any: ... + def __init__(self, itemtype: str, cnf: dict[str, Any] = ..., *, master: tkinter.Widget | None = ..., **kw) -> None: ... + def __getitem__(self, key: str): ... def __setitem__(self, key: str, value: Any) -> None: ... def delete(self) -> None: ... - def config(self, cnf: dict[str, Any] = ..., **kw: Any) -> Any: ... + def config(self, cnf: dict[str, Any] = ..., **kw): ... class Balloon(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def bind_widget(self, widget: tkinter.Widget, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... + def bind_widget(self, widget: tkinter.Widget, cnf: dict[str, Any] = ..., **kw) -> None: ... def unbind_widget(self, widget: tkinter.Widget) -> None: ... class ButtonBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = ..., **kw) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class ComboBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def add_history(self, str: str) -> None: ... def append_history(self, str: str) -> None: ... def insert(self, index: int, str: str) -> None: ... def pick(self, index: int) -> None: ... class Control(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def decrement(self) -> None: ... def increment(self) -> None: ... def invoke(self) -> None: ... class LabelEntry(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... class LabelFrame(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... class Meter(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... class OptionMenu(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add_command(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add_separator(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... + def add_command(self, name: str, cnf: dict[str, Any] = ..., **kw) -> None: ... + def add_separator(self, name: str, cnf: dict[str, Any] = ..., **kw) -> None: ... def delete(self, name: str) -> None: ... def disable(self, name: str) -> None: ... def enable(self, name: str) -> None: ... class PopupMenu(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def bind_widget(self, widget: tkinter.Widget) -> None: ... def unbind_widget(self, widget: tkinter.Widget) -> None: ... def post_widget(self, widget: tkinter.Widget, x: int, y: int) -> None: ... class Select(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = ..., **kw) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class StdButtonBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def invoke(self, name: str) -> None: ... class DirList(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirTree(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirSelectDialog(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def popup(self) -> None: ... def popdown(self) -> None: ... class DirSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... class ExFileSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def filter(self) -> None: ... def invoke(self) -> None: ... class FileSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def apply_filter(self) -> None: ... def invoke(self) -> None: ... class FileEntry(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... def invoke(self) -> None: ... def file_dialog(self) -> None: ... class HList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, entry: str, cnf: dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... - def add_child(self, parent: str | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> tkinter.Widget: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, entry: str, cnf: dict[str, Any] = ..., **kw) -> tkinter.Widget: ... + def add_child(self, parent: str | None = ..., cnf: dict[str, Any] = ..., **kw) -> tkinter.Widget: ... def anchor_set(self, entry: str) -> None: ... def anchor_clear(self) -> None: ... # FIXME: Overload, certain combos return, others don't @@ -178,17 +179,17 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def dragsite_clear(self) -> None: ... def dropsite_set(self, index: int) -> None: ... def dropsite_clear(self) -> None: ... - def header_create(self, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def header_configure(self, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... - def header_cget(self, col: int, opt: Any) -> Any: ... + def header_create(self, col: int, cnf: dict[str, Any] = ..., **kw) -> None: ... + def header_configure(self, col: int, cnf: dict[str, Any] = ..., **kw) -> Incomplete | None: ... + def header_cget(self, col: int, opt): ... def header_exists(self, col: int) -> bool: ... def header_exist(self, col: int) -> bool: ... def header_delete(self, col: int) -> None: ... def header_size(self, col: int) -> int: ... def hide_entry(self, entry: str) -> None: ... - def indicator_create(self, entry: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def indicator_configure(self, entry: str, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... - def indicator_cget(self, entry: str, opt: Any) -> Any: ... + def indicator_create(self, entry: str, cnf: dict[str, Any] = ..., **kw) -> None: ... + def indicator_configure(self, entry: str, cnf: dict[str, Any] = ..., **kw) -> Incomplete | None: ... + def indicator_cget(self, entry: str, opt): ... def indicator_exists(self, entry: str) -> bool: ... def indicator_delete(self, entry: str) -> None: ... def indicator_size(self, entry: str) -> int: ... @@ -204,22 +205,22 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def info_parent(self, entry: str) -> str: ... def info_prev(self, entry: str) -> str: ... def info_selection(self) -> tuple[str, ...]: ... - def item_cget(self, entry: str, col: int, opt: Any) -> Any: ... - def item_configure(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... - def item_create(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def item_cget(self, entry: str, col: int, opt): ... + def item_configure(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw) -> Incomplete | None: ... + def item_create(self, entry: str, col: int, cnf: dict[str, Any] = ..., **kw) -> None: ... def item_exists(self, entry: str, col: int) -> bool: ... def item_delete(self, entry: str, col: int) -> None: ... - def entrycget(self, entry: str, opt: Any) -> Any: ... - def entryconfigure(self, entry: str, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... + def entrycget(self, entry: str, opt): ... + def entryconfigure(self, entry: str, cnf: dict[str, Any] = ..., **kw) -> Incomplete | None: ... def nearest(self, y: int) -> str: ... def see(self, entry: str) -> None: ... - def selection_clear(self, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def selection_clear(self, cnf: dict[str, Any] = ..., **kw) -> None: ... def selection_includes(self, entry: str) -> bool: ... def selection_set(self, first: str, last: str | None = ...) -> None: ... def show_entry(self, entry: str) -> None: ... class CheckList(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -229,7 +230,7 @@ class CheckList(TixWidget): def setstatus(self, entrypath: str, mode: str = ...) -> None: ... class Tree(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -237,7 +238,7 @@ class Tree(TixWidget): def setmode(self, entrypath: str, mode: str = ...) -> None: ... class TList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... def active_set(self, index: int) -> None: ... def active_clear(self) -> None: ... def anchor_set(self, index: int) -> None: ... @@ -247,7 +248,7 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def dragsite_clear(self) -> None: ... def dropsite_set(self, index: int) -> None: ... def dropsite_clear(self) -> None: ... - def insert(self, index: int, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def insert(self, index: int, cnf: dict[str, Any] = ..., **kw) -> None: ... def info_active(self) -> int: ... def info_anchor(self) -> int: ... def info_down(self, index: int) -> int: ... @@ -258,29 +259,29 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def info_up(self, index: int) -> int: ... def nearest(self, x: int, y: int) -> int: ... def see(self, index: int) -> None: ... - def selection_clear(self, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def selection_clear(self, cnf: dict[str, Any] = ..., **kw) -> None: ... def selection_includes(self, index: int) -> bool: ... def selection_set(self, first: int, last: int | None = ...) -> None: ... class PanedWindow(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = ..., **kw) -> None: ... def delete(self, name: str) -> None: ... def forget(self, name: str) -> None: ... # type: ignore[override] - def panecget(self, entry: str, opt: Any) -> Any: ... - def paneconfigure(self, entry: str, cnf: dict[str, Any] = ..., **kw: Any) -> Any | None: ... + def panecget(self, entry: str, opt): ... + def paneconfigure(self, entry: str, cnf: dict[str, Any] = ..., **kw) -> Incomplete | None: ... def panes(self) -> list[tkinter.Widget]: ... class ListNoteBook(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = ..., **kw) -> None: ... def page(self, name: str) -> tkinter.Widget: ... def pages(self) -> list[tkinter.Widget]: ... def raise_page(self, name: str) -> None: ... class NoteBook(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = ..., **kw) -> None: ... def delete(self, name: str) -> None: ... def page(self, name: str) -> tkinter.Widget: ... def pages(self) -> list[tkinter.Widget]: ... @@ -288,14 +289,14 @@ class NoteBook(TixWidget): def raised(self) -> bool: ... class InputOnly(TixWidget): - def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def __init__(self, master: tkinter.Widget | None = ..., cnf: dict[str, Any] = ..., **kw) -> None: ... class Form: def __setitem__(self, key: str, value: Any) -> None: ... - def config(self, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... - def form(self, cnf: dict[str, Any] = ..., **kw: Any) -> None: ... + def config(self, cnf: dict[str, Any] = ..., **kw) -> None: ... + def form(self, cnf: dict[str, Any] = ..., **kw) -> None: ... def check(self) -> bool: ... def forget(self) -> None: ... def grid(self, xsize: int = ..., ysize: int = ...) -> tuple[int, int] | None: ... - def info(self, option: str | None = ...) -> Any: ... + def info(self, option: str | None = ...): ... def slaves(self) -> list[tkinter.Widget]: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 810772002..8e9890207 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,6 +1,7 @@ import _tkinter import sys import tkinter +from _typeshed import Incomplete from collections.abc import Callable from tkinter.font import _FontDescription from typing import Any, overload @@ -35,23 +36,23 @@ __all__ = [ ] def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ... -def setup_master(master: Any | None = ...): ... +def setup_master(master: Incomplete | None = ...): ... # from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound _TtkCompound: TypeAlias = Literal["text", "image", tkinter._Compound] class Style: - master: Any + master: Incomplete tk: _tkinter.TkappType def __init__(self, master: tkinter.Misc | None = ...) -> None: ... - def configure(self, style, query_opt: Any | None = ..., **kw): ... - def map(self, style, query_opt: Any | None = ..., **kw): ... - def lookup(self, style, option, state: Any | None = ..., default: Any | None = ...): ... - def layout(self, style, layoutspec: Any | None = ...): ... + def configure(self, style, query_opt: Incomplete | None = ..., **kw): ... + def map(self, style, query_opt: Incomplete | None = ..., **kw): ... + def lookup(self, style, option, state: Incomplete | None = ..., default: Incomplete | None = ...): ... + def layout(self, style, layoutspec: Incomplete | None = ...): ... def element_create(self, elementname, etype, *args, **kw) -> None: ... def element_names(self): ... def element_options(self, elementname): ... - def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...) -> None: ... + def theme_create(self, themename, parent: Incomplete | None = ..., settings: Incomplete | None = ...) -> None: ... def theme_settings(self, themename, settings) -> None: ... def theme_names(self) -> tuple[str, ...]: ... @overload @@ -60,10 +61,10 @@ class Style: def theme_use(self, themename: None = ...) -> str: ... class Widget(tkinter.Widget): - def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...) -> None: ... + def __init__(self, master: tkinter.Misc | None, widgetname, kw: Incomplete | None = ...) -> None: ... def identify(self, x: int, y: int) -> str: ... - def instate(self, statespec, callback: Any | None = ..., *args, **kw): ... - def state(self, statespec: Any | None = ...): ... + def instate(self, statespec, callback: Incomplete | None = ..., *args, **kw): ... + def state(self, statespec: Incomplete | None = ...): ... class Button(Widget): def __init__( @@ -77,7 +78,7 @@ class Button(Widget): default: Literal["normal", "active", "disabled"] = ..., image: tkinter._ImageSpec = ..., name: str = ..., - padding: Any = ..., # undocumented + padding: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -96,7 +97,7 @@ class Button(Widget): cursor: tkinter._Cursor = ..., default: Literal["normal", "active", "disabled"] = ..., image: tkinter._ImageSpec = ..., - padding: Any = ..., + padding: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -123,7 +124,7 @@ class Checkbutton(Widget): name: str = ..., offvalue: Any = ..., onvalue: Any = ..., - padding: Any = ..., # undocumented + padding: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -147,7 +148,7 @@ class Checkbutton(Widget): image: tkinter._ImageSpec = ..., offvalue: Any = ..., onvalue: Any = ..., - padding: Any = ..., + padding: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -255,8 +256,8 @@ class Combobox(Entry): invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = ..., name: str = ..., - postcommand: Callable[[], Any] | str = ..., - show: Any = ..., # undocumented + postcommand: Callable[[], object] | str = ..., + show: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -280,8 +281,8 @@ class Combobox(Entry): height: int = ..., invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., - postcommand: Callable[[], Any] | str = ..., - show: Any = ..., + postcommand: Callable[[], object] | str = ..., + show: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -308,8 +309,8 @@ class Combobox(Entry): height: int = ..., invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., - postcommand: Callable[[], Any] | str = ..., - show: Any = ..., + postcommand: Callable[[], object] | str = ..., + show: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -477,7 +478,7 @@ class Menubutton(Widget): image: tkinter._ImageSpec = ..., menu: tkinter.Menu = ..., name: str = ..., - padding: Any = ..., # undocumented + padding: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -496,7 +497,7 @@ class Menubutton(Widget): direction: Literal["above", "below", "left", "right", "flush"] = ..., image: tkinter._ImageSpec = ..., menu: tkinter.Menu = ..., - padding: Any = ..., + padding: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -546,7 +547,7 @@ class Notebook(Widget): sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty padding: tkinter._Padding = ..., text: str = ..., - image: Any = ..., # Sequence of an image name, followed by zero or more (sequences of one or more state names followed by an image name) + image: Incomplete = ..., # Sequence of an image name, followed by zero or more (sequences of one or more state names followed by an image name) compound: tkinter._Compound = ..., underline: int = ..., ) -> None: ... @@ -555,8 +556,8 @@ class Notebook(Widget): def identify(self, x: int, y: int) -> str: ... def index(self, tab_id): ... def insert(self, pos, child, **kw) -> None: ... - def select(self, tab_id: Any | None = ...): ... - def tab(self, tab_id, option: Any | None = ..., **kw): ... + def select(self, tab_id: Incomplete | None = ...): ... + def tab(self, tab_id, option: Incomplete | None = ..., **kw): ... def tabs(self): ... def enable_traversal(self) -> None: ... @@ -603,10 +604,10 @@ class Panedwindow(Widget, tkinter.PanedWindow): ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... - forget: Any + forget: Incomplete def insert(self, pos, child, **kw) -> None: ... - def pane(self, pane, option: Any | None = ..., **kw): ... - def sashpos(self, index, newpos: Any | None = ...): ... + def pane(self, pane, option: Incomplete | None = ..., **kw): ... + def sashpos(self, index, newpos: Incomplete | None = ...): ... PanedWindow = Panedwindow @@ -662,7 +663,7 @@ class Radiobutton(Widget): cursor: tkinter._Cursor = ..., image: tkinter._ImageSpec = ..., name: str = ..., - padding: Any = ..., # undocumented + padding: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -682,7 +683,7 @@ class Radiobutton(Widget): compound: _TtkCompound = ..., cursor: tkinter._Cursor = ..., image: tkinter._ImageSpec = ..., - padding: Any = ..., + padding: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -705,7 +706,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] master: tkinter.Misc | None = ..., *, class_: str = ..., - command: str | Callable[[str], Any] = ..., + command: str | Callable[[str], object] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -723,7 +724,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] self, cnf: dict[str, Any] | None = ..., *, - command: str | Callable[[str], Any] = ..., + command: str | Callable[[str], object] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -743,7 +744,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] self, cnf: dict[str, Any] | None = ..., *, - command: str | Callable[[str], Any] = ..., + command: str | Callable[[str], object] = ..., cursor: tkinter._Cursor = ..., from_: float = ..., length: tkinter._ScreenUnits = ..., @@ -858,7 +859,7 @@ class Spinbox(Entry): *, background: tkinter._Color = ..., # undocumented class_: str = ..., - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented @@ -869,7 +870,7 @@ class Spinbox(Entry): invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = ..., # undocumented name: str = ..., - show: Any = ..., # undocumented + show: Incomplete = ..., # undocumented state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -888,7 +889,7 @@ class Spinbox(Entry): cnf: dict[str, Any] | None = ..., *, background: tkinter._Color = ..., - command: Callable[[], Any] | str | list[str] | tuple[str, ...] = ..., + command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., @@ -898,7 +899,7 @@ class Spinbox(Entry): increment: float = ..., invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., - show: Any = ..., + show: Incomplete = ..., state: str = ..., style: str = ..., takefocus: tkinter._TakeFocusValue = ..., @@ -1042,7 +1043,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): text: str = ..., image: tkinter._ImageSpec = ..., anchor: tkinter._Anchor = ..., - command: str | Callable[[], Any] = ..., + command: str | Callable[[], object] = ..., ) -> None: ... def identify(self, component, x, y): ... # Internal Method. Leave untyped def identify_row(self, y: int) -> str: ... @@ -1098,7 +1099,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): if sys.version_info >= (3, 8): def selection(self) -> tuple[str, ...]: ... else: - def selection(self, selop: Any | None = ..., items: Any | None = ...) -> tuple[str, ...]: ... + def selection(self, selop: Incomplete | None = ..., items: Incomplete | None = ...) -> tuple[str, ...]: ... def selection_set(self, items: str | list[str] | tuple[str, ...]) -> None: ... def selection_add(self, items: str | list[str] | tuple[str, ...]) -> None: ... @@ -1114,7 +1115,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # Also, it's 'callback' instead of 'func' here. @overload def tag_bind( - self, tagname: str, sequence: str | None = ..., callback: Callable[[tkinter.Event[Treeview]], Any] | None = ... + self, tagname: str, sequence: str | None = ..., callback: Callable[[tkinter.Event[Treeview]], object] | None = ... ) -> str: ... @overload def tag_bind(self, tagname: str, sequence: str | None, callback: str) -> None: ... @@ -1144,8 +1145,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): def tag_has(self, tagname: str, item: str) -> bool: ... class LabeledScale(Frame): - label: Any - scale: Any + label: Incomplete + scale: Incomplete # TODO: don't any-type **kw. That goes to Frame.__init__. def __init__( self, @@ -1155,7 +1156,7 @@ class LabeledScale(Frame): to: float = ..., *, compound: Literal["top", "bottom"] = ..., - **kw: Any, + **kw, ) -> None: ... # destroy is overridden, signature does not change value: Any @@ -1170,8 +1171,8 @@ class OptionMenu(Menubutton): # rest of these are keyword-only because *args syntax used above style: str = ..., direction: Literal["above", "below", "left", "right", "flush"] = ..., - command: Callable[[tkinter.StringVar], Any] | None = ..., + command: Callable[[tkinter.StringVar], object] | None = ..., ) -> None: ... # configure, config, cget, destroy are inherited from Menubutton # destroy and __setitem__ are overridden, signature does not change - def set_menu(self, default: Any | None = ..., *values) -> None: ... + def set_menu(self, default: Incomplete | None = ..., *values) -> None: ...