Skip to content

[tkinter] Allow any return value for invalidcommand - #16252

Merged
Akuli merged 2 commits into
python:mainfrom
ekanshul:tkinter-invalidcommand-return-object
Aug 26, 2026
Merged

[tkinter] Allow any return value for invalidcommand#16252
Akuli merged 2 commits into
python:mainfrom
ekanshul:tkinter-invalidcommand-return-object

Conversation

@ekanshul

Copy link
Copy Markdown
Contributor

Closes #10578

Widen invalidcommand/invcmd from Callable[[], bool] to Callable[[], object] on all Entry, Spinbox, ttk.Entry, ttk.Combobox and ttk.Spinbox sites, as suggested in the issue; validatecommand is unchanged.

Agent used: Claude Code

Tk only evaluates the invalidcommand (invcmd) script when validatecommand
returns false and ignores whatever it returns, so Callable[[], bool] was
too strict and rejected ordinary callbacks that return None. Widen it to
Callable[[], object] on all Entry, Spinbox, ttk.Entry, ttk.Combobox and
ttk.Spinbox sites. validatecommand keeps Callable[[], bool] because Tk
does use its result.

Closes python#10578

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@srittau
srittau requested a review from Akuli August 25, 2026 10:02
@github-actions

Copy link
Copy Markdown
Contributor

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

@Akuli Akuli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Akuli
Akuli merged commit e5c129d into python:main Aug 26, 2026
88 checks passed
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.

Typeshed for tkinter invalidcommand is not correct

3 participants