Skip to content

Commit 78a12c6

Browse files
tkinter: add **kwargs support to tkinter.Misc.after for 3.14 (#15720)
In Python 3.14, python/cpython#126900 added kwargs support to `tkinter.Misc.after`. stubtest missed this because we allowlist the function for a different reason. Found by Codex along with #15717 (I didn't include it in that PR because I incorrectly convinced myself this one was more complicated). It also found missing **kwargs support for some asyncio create_task functions, but we already have issues/PRs about that (e.g. #13687).
1 parent 2d78fda commit 78a12c6

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

stdlib/tkinter/__init__.pyi

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ from typing import (
1212
Generic,
1313
Literal,
1414
NamedTuple,
15+
ParamSpec,
1516
Protocol,
1617
TypeAlias,
1718
TypedDict,
@@ -376,6 +377,7 @@ getdouble = float
376377
def getboolean(s) -> bool: ...
377378

378379
_Ts = TypeVarTuple("_Ts")
380+
_P = ParamSpec("_P")
379381

380382
@type_check_only
381383
class _GridIndexInfo(TypedDict, total=False):
@@ -415,11 +417,19 @@ class Misc:
415417
def tk_focusFollowsMouse(self) -> None: ...
416418
def tk_focusNext(self) -> Misc | None: ...
417419
def tk_focusPrev(self) -> Misc | None: ...
418-
# .after() can be called without the "func" argument, but it is basically never what you want.
419-
# It behaves like time.sleep() and freezes the GUI app.
420-
def after(self, ms: int | Literal["idle"], func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> str: ...
421-
# after_idle is essentially partialmethod(after, "idle")
422-
def after_idle(self, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> str: ...
420+
if sys.version_info >= (3, 14):
421+
# .after() can be called without the "func" argument, but it is basically never what you want.
422+
# It behaves like time.sleep() and freezes the GUI app.
423+
def after(self, ms: int | Literal["idle"], func: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> str: ...
424+
# after_idle is essentially partialmethod(after, "idle")
425+
def after_idle(self, func: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> str: ...
426+
else:
427+
# .after() can be called without the "func" argument, but it is basically never what you want.
428+
# It behaves like time.sleep() and freezes the GUI app.
429+
def after(self, ms: int | Literal["idle"], func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> str: ...
430+
# after_idle is essentially partialmethod(after, "idle")
431+
def after_idle(self, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> str: ...
432+
423433
def after_cancel(self, id: str) -> None: ...
424434
if sys.version_info >= (3, 13):
425435
def after_info(self, id: str | None = None) -> tuple[str, ...]: ...

0 commit comments

Comments
 (0)