Skip to content

Commit 3f727b0

Browse files
GameRoManAkuli
andauthored
Add type annotations for **options in tkinter.messagebox functions (#14341)
Co-authored-by: Akuli <[email protected]>
1 parent 0b887a5 commit 3f727b0

File tree

2 files changed

+75
-10
lines changed

2 files changed

+75
-10
lines changed

stdlib/tkinter/commondialog.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ class Dialog:
1111
# sometimes changed to a different type.
1212
options: Mapping[str, Any]
1313
def __init__(self, master: Misc | None = None, **options: Any) -> None: ...
14-
def show(self, **options: Any): ...
14+
def show(self, **options: Any) -> Any: ...

stdlib/tkinter/messagebox.pyi

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
from tkinter import Misc
12
from tkinter.commondialog import Dialog
2-
from typing import ClassVar, Final
3+
from typing import ClassVar, Final, Literal
34

45
__all__ = ["showinfo", "showwarning", "showerror", "askquestion", "askokcancel", "askyesno", "askyesnocancel", "askretrycancel"]
56

@@ -23,11 +24,75 @@ NO: Final = "no"
2324
class Message(Dialog):
2425
command: ClassVar[str]
2526

26-
def showinfo(title: str | None = None, message: str | None = None, **options) -> str: ...
27-
def showwarning(title: str | None = None, message: str | None = None, **options) -> str: ...
28-
def showerror(title: str | None = None, message: str | None = None, **options) -> str: ...
29-
def askquestion(title: str | None = None, message: str | None = None, **options) -> str: ...
30-
def askokcancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
31-
def askyesno(title: str | None = None, message: str | None = None, **options) -> bool: ...
32-
def askyesnocancel(title: str | None = None, message: str | None = None, **options) -> bool | None: ...
33-
def askretrycancel(title: str | None = None, message: str | None = None, **options) -> bool: ...
27+
def showinfo(
28+
title: str | None = None,
29+
message: str | None = None,
30+
*,
31+
detail: str = ...,
32+
icon: Literal["error", "info", "question", "warning"] = ...,
33+
default: Literal["ok"] = ...,
34+
parent: Misc = ...,
35+
) -> str: ...
36+
def showwarning(
37+
title: str | None = None,
38+
message: str | None = None,
39+
*,
40+
detail: str = ...,
41+
icon: Literal["error", "info", "question", "warning"] = ...,
42+
default: Literal["ok"] = ...,
43+
parent: Misc = ...,
44+
) -> str: ...
45+
def showerror(
46+
title: str | None = None,
47+
message: str | None = None,
48+
*,
49+
detail: str = ...,
50+
icon: Literal["error", "info", "question", "warning"] = ...,
51+
default: Literal["ok"] = ...,
52+
parent: Misc = ...,
53+
) -> str: ...
54+
def askquestion(
55+
title: str | None = None,
56+
message: str | None = None,
57+
*,
58+
detail: str = ...,
59+
icon: Literal["error", "info", "question", "warning"] = ...,
60+
default: Literal["yes", "no"] = ...,
61+
parent: Misc = ...,
62+
) -> str: ...
63+
def askokcancel(
64+
title: str | None = None,
65+
message: str | None = None,
66+
*,
67+
detail: str = ...,
68+
icon: Literal["error", "info", "question", "warning"] = ...,
69+
default: Literal["ok", "cancel"] = ...,
70+
parent: Misc = ...,
71+
) -> bool: ...
72+
def askyesno(
73+
title: str | None = None,
74+
message: str | None = None,
75+
*,
76+
detail: str = ...,
77+
icon: Literal["error", "info", "question", "warning"] = ...,
78+
default: Literal["yes", "no"] = ...,
79+
parent: Misc = ...,
80+
) -> bool: ...
81+
def askyesnocancel(
82+
title: str | None = None,
83+
message: str | None = None,
84+
*,
85+
detail: str = ...,
86+
icon: Literal["error", "info", "question", "warning"] = ...,
87+
default: Literal["cancel", "yes", "no"] = ...,
88+
parent: Misc = ...,
89+
) -> bool | None: ...
90+
def askretrycancel(
91+
title: str | None = None,
92+
message: str | None = None,
93+
*,
94+
detail: str = ...,
95+
icon: Literal["error", "info", "question", "warning"] = ...,
96+
default: Literal["retry", "cancel"] = ...,
97+
parent: Misc = ...,
98+
) -> bool: ...

0 commit comments

Comments
 (0)