[tkinter] Annotate few methods (#15273)

This commit is contained in:
Semyon Moroz
2026-01-15 23:28:12 +00:00
committed by GitHub
parent 5e477a316c
commit ee1e94d430
2 changed files with 53 additions and 34 deletions
+24 -15
View File
@@ -1,6 +1,6 @@
import _tkinter
import sys
from _typeshed import Incomplete, MaybeNone, StrOrBytesPath
from _typeshed import FileDescriptorLike, Incomplete, MaybeNone, StrOrBytesPath
from collections.abc import Callable, Iterable, Mapping, Sequence
from tkinter.constants import *
from tkinter.font import _FontDescription
@@ -1005,34 +1005,43 @@ class Tk(Misc, Wm):
# Tk has __getattr__ so that tk_instance.foo falls back to tk_instance.tk.foo
# Please keep in sync with _tkinter.TkappType.
# Some methods are intentionally missing because they are inherited from Misc instead.
def adderrorinfo(self, msg: str, /): ...
def adderrorinfo(self, msg: str, /) -> None: ...
def call(self, command: Any, /, *args: Any) -> Any: ...
def createcommand(self, name: str, func, /): ...
# TODO: Figure out what arguments the following `func` callbacks should accept
def createcommand(self, name: str, func: Callable[..., object], /) -> None: ...
if sys.platform != "win32":
def createfilehandler(self, file, mask: int, func, /): ...
def deletefilehandler(self, file, /) -> None: ...
def createfilehandler(self, file: FileDescriptorLike, mask: int, func: Callable[..., object], /) -> None: ...
def deletefilehandler(self, file: FileDescriptorLike, /) -> None: ...
def createtimerhandler(self, milliseconds: int, func, /): ...
def dooneevent(self, flags: int = 0, /): ...
def createtimerhandler(self, milliseconds: int, func: Callable[..., object], /): ...
def dooneevent(self, flags: int = 0, /) -> int: ...
def eval(self, script: str, /) -> str: ...
def evalfile(self, fileName: str, /): ...
def exprboolean(self, s: str, /): ...
def exprdouble(self, s: str, /): ...
def exprlong(self, s: str, /): ...
def exprstring(self, s: str, /): ...
def evalfile(self, fileName: str, /) -> str: ...
def exprboolean(self, s: str, /) -> Literal[0, 1]: ...
def exprdouble(self, s: str, /) -> float: ...
def exprlong(self, s: str, /) -> int: ...
def exprstring(self, s: str, /) -> str: ...
def globalgetvar(self, *args, **kwargs): ...
def globalsetvar(self, *args, **kwargs): ...
def globalunsetvar(self, *args, **kwargs): ...
def interpaddr(self) -> int: ...
def loadtk(self) -> None: ...
def record(self, script: str, /): ...
def record(self, script: str, /) -> str: ...
if sys.version_info < (3, 11):
@deprecated("Deprecated since Python 3.9; removed in Python 3.11. Use `splitlist()` instead.")
def split(self, arg, /): ...
def splitlist(self, arg, /): ...
def splitlist(self, arg, /) -> tuple[Incomplete, ...]: ...
def unsetvar(self, *args, **kwargs): ...
def wantobjects(self, *args, **kwargs): ...
if sys.version_info >= (3, 14):
@overload
def wantobjects(self) -> Literal[0, 1]: ...
else:
@overload
def wantobjects(self) -> bool: ...
@overload
def wantobjects(self, wantobjects: Literal[0, 1] | bool, /) -> None: ...
def willdispatch(self) -> None: ...
def Tcl(screenName: str | None = None, baseName: str | None = None, className: str = "Tk", useTk: bool = False) -> Tk: ...