Skip to content

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

Open
ekanshul wants to merge 1 commit into
python:mainfrom
ekanshul:tkinter-invalidcommand-return-object
Open

[tkinter] Allow any return value for invalidcommand#16252
ekanshul wants to merge 1 commit into
python:mainfrom
ekanshul:tkinter-invalidcommand-return-object

Conversation

@ekanshul

Copy link
Copy Markdown

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

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.

Typeshed for tkinter invalidcommand is not correct

1 participant