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

Skip to content

Add explicit Any type 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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GameRoMan
Copy link

Add explicit **options: Any to all tkinter.messagebox functions to remove "partially unknown type" warnings from type checkers like Pyright and Pylance

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@Akuli
Copy link
Collaborator

Akuli commented Jun 26, 2025

Thanks. This is not quite right; it would be better to add individually all options that these functions accept and their types.

For example, like this:

def showinfo(
    title: str | None = None,
    message: str | None = None,
    *,
    detail: str = ...,
    icon: Literal["error", "info", "question", "warning"] = ...,
    parent: tkinter.Misc = ...,
) -> str: ...

To figure out what options exist, you can pass an invalid option and look at the error message. Try tkinter.messagebox.showinfo(asdf="") for example.

To figure out what each option does, you can try it, or look at the manual here: https://www.tcl-lang.org/man/tcl8.6/TkCmd/messageBox.htm

Let me know if anything is unclear. Tkinter stubs are more difficult than you'd expect :) Also, if this is more work than you want to do, you can just close this PR and wait for someone else (probably me) to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants