Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cad0c04

Browse files
authored
tkinter: Require passing in a callback function to .after() (#11013)
1 parent cc0b41a commit cad0c04

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

stdlib/tkinter/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,8 @@ class Misc:
347347
def tk_focusFollowsMouse(self) -> None: ...
348348
def tk_focusNext(self) -> Misc | None: ...
349349
def tk_focusPrev(self) -> Misc | None: ...
350-
@overload
351-
def after(self, ms: int, func: None = None) -> None: ...
352-
@overload
350+
# .after() can be called without the "func" argument, but it is basically never what you want.
351+
# It behaves like time.sleep() and freezes the GUI app.
353352
def after(self, ms: int | Literal["idle"], func: Callable[..., object], *args: Any) -> str: ...
354353
# after_idle is essentially partialmethod(after, "idle")
355354
def after_idle(self, func: Callable[..., object], *args: Any) -> str: ...

tests/stubtest_allowlists/py3_common.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ tkinter.simpledialog.TkVersion
123123
tkinter.tix.[A-Z_]+
124124
tkinter.tix.TclVersion
125125
tkinter.tix.TkVersion
126+
tkinter.Misc.after # we intentionally don't allow everything that "works" at runtime
126127
traceback.TracebackException.from_exception # explicitly expanding arguments going into TracebackException __init__
127128
typing(_extensions)?\.IO\.__next__ # Added because IO streams are iterable. See https://github.com/python/typeshed/commit/97bc450acd60c1bcdafef3ce8fbe3b95a9c0cac3
128129
typing.type_check_only # typing decorator that is not available at runtime

0 commit comments

Comments
 (0)