Skip to content

Fix tkinter.OptionMenu callback type - #16113

Open
subotac wants to merge 1 commit into
python:mainfrom
subotac:fix/tkinter-optionmenu-callback
Open

Fix tkinter.OptionMenu callback type#16113
subotac wants to merge 1 commit into
python:mainfrom
subotac:fix/tkinter-optionmenu-callback

Conversation

@subotac

@subotac subotac commented Jul 30, 2026

Copy link
Copy Markdown

OptionMenu passes the selected menu value to _setit, which invokes the callback with that value rather than the StringVar. Update both version-specific signatures to type the callback argument
as str, and add a regression test for callback inference.

CPython implementation: https://github.com/python/cpython/blob/main/Lib/tkinter/__init__.py#L4573-L4615

Fixes #16111

@github-actions

Copy link
Copy Markdown
Contributor

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

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.

tkinter.OptionMenu(command=...) type hint wrong

1 participant