Add type annotations for **options in tkinter.messagebox functions (#14341)

Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
Roman A
2025-06-30 23:13:40 +01:00
committed by GitHub
parent 0b887a54ff
commit 3f727b0cd6
2 changed files with 75 additions and 10 deletions
+1 -1
View File
@@ -11,4 +11,4 @@ class Dialog:
# sometimes changed to a different type.
options: Mapping[str, Any]
def __init__(self, master: Misc | None = None, **options: Any) -> None: ...
def show(self, **options: Any): ...
def show(self, **options: Any) -> Any: ...
+74 -9
View File
@@ -1,5 +1,6 @@
from tkinter import Misc
from tkinter.commondialog import Dialog
from typing import ClassVar, Final
from typing import ClassVar, Final, Literal
__all__ = ["showinfo", "showwarning", "showerror", "askquestion", "askokcancel", "askyesno", "askyesnocancel", "askretrycancel"]
@@ -23,11 +24,75 @@ NO: Final = "no"
class Message(Dialog):
command: ClassVar[str]
def showinfo(title: str | None = None, message: str | None = None, **options) -> str: ...
def showwarning(title: str | None = None, message: str | None = None, **options) -> str: ...
def showerror(title: str | None = None, message: str | None = None, **options) -> str: ...
def askquestion(title: str | None = None, message: str | None = None, **options) -> str: ...
def askokcancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
def askyesno(title: str | None = None, message: str | None = None, **options) -> bool: ...
def askyesnocancel(title: str | None = None, message: str | None = None, **options) -> bool | None: ...
def askretrycancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
def showinfo(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["ok"] = ...,
parent: Misc = ...,
) -> str: ...
def showwarning(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["ok"] = ...,
parent: Misc = ...,
) -> str: ...
def showerror(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["ok"] = ...,
parent: Misc = ...,
) -> str: ...
def askquestion(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["yes", "no"] = ...,
parent: Misc = ...,
) -> str: ...
def askokcancel(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["ok", "cancel"] = ...,
parent: Misc = ...,
) -> bool: ...
def askyesno(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["yes", "no"] = ...,
parent: Misc = ...,
) -> bool: ...
def askyesnocancel(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["cancel", "yes", "no"] = ...,
parent: Misc = ...,
) -> bool | None: ...
def askretrycancel(
title: str | None = None,
message: str | None = None,
*,
detail: str = ...,
icon: Literal["error", "info", "question", "warning"] = ...,
default: Literal["retry", "cancel"] = ...,
parent: Misc = ...,
) -> bool: ...