Open
Description
The typeshed for tkinter ttk.Entry.invalidcommand
uses tkinter._EntryValidateCommand
type annotation which means
TypeAlias = str | list[str] | tuple[str, ...] | Callable[[], bool]
https://github.com/search?q=repo%3Apython%2Ftypeshed%20invalidcommand&type=code
but it should use something like
Callable[[], None]
invalidcommand
is just a function that is called when the validatecommand
returns False. I think it is undocumented in the Python docs.
Example snippet for tests:
from tkinter import DoubleVar, Tk
from tkinter.ttk import Button, Entry, Frame, Label
root = Tk()
root.resizable(False, False)
validate_value = root.register(lambda value: False), "%P"
frame = Frame(root, padding=10)
frame.grid()
Label(frame, text="Hello World!").grid(column=0, row=0)
txt = DoubleVar(value=4.5)
Label(frame, textvariable=txt).grid(column=1, row=1)
Entry(
frame,
textvariable=txt,
validate="all",
validatecommand=validate_value,
invalidcommand=lambda: print("Validation error!"), # <-- Wrong typeshed
).grid(column=1, row=2)
Button(frame, text="Quit", command=root.destroy).grid(column=2, row=3)
root.mainloop()
The lambda below should be allowed here:

But it is marked as an error by Pyright due to the wrong typeshed.
This issue is moved from microsoft/pyright#5720