@@ -4,7 +4,7 @@ import tkinter
44from _typeshed import MaybeNone
55from collections .abc import Callable , Iterable , Sequence
66from tkinter .font import _FontDescription
7- from typing import Any , Literal , TypedDict , overload , type_check_only
7+ from typing import Any , Literal , TypedDict , TypeVar , overload , type_check_only
88from typing_extensions import Never , TypeAlias , Unpack
99
1010__all__ = [
@@ -54,6 +54,9 @@ _Statespec: TypeAlias = tuple[Unpack[tuple[str, ...]], Any]
5454_ImageStatespec : TypeAlias = tuple [Unpack [tuple [str , ...]], tkinter ._Image | str ]
5555_VsapiStatespec : TypeAlias = tuple [Unpack [tuple [str , ...]], int ]
5656
57+ P = ParamSpec ("P" )
58+ T = TypeVar ("T" )
59+
5760class _Layout (TypedDict , total = False ):
5861 side : Literal ["left" , "right" , "top" , "bottom" ]
5962 sticky : str # consists of letters 'n', 's', 'w', 'e', may contain repeats, may be empty
@@ -203,9 +206,10 @@ class Style:
203206class Widget (tkinter .Widget ):
204207 def __init__ (self , master : tkinter .Misc | None , widgetname : str | None , kw : dict [str , Any ] | None = None ) -> None : ...
205208 def identify (self , x : int , y : int ) -> str : ...
206- def instate (
207- self , statespec : Sequence [str ], callback : Callable [..., Any ] | None = None , * args : Any , ** kw : Any
208- ) -> bool | Any : ...
209+ @overload
210+ def instate (self , statespec : Sequence [str ], callback : None = None ) -> bool : ...
211+ @overload
212+ def instate (self , statespec : Sequence [str ], callback : Callable [P , T ], * args : P .args , ** kw : P .kwargs ) -> bool | T : ...
209213 def state (self , statespec : Sequence [str ] | None = None ) -> tuple [str , ...]: ...
210214
211215class Button (Widget ):
0 commit comments