Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/tkinter/commondialog.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
83 changes: 74 additions & 9 deletions stdlib/tkinter/messagebox.pyi
Original file line number Diff line number Diff line change
@@ -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"]

Expand All @@ -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: ...