I have a callback
from tkinter import font, ttk
class Foo(ttk.Frame):
def set_font_cb(self, event: tk.Event) -> None:
event.widget.configure(font=font.Font(...))
And this creates in mypy as well as in pylance an error:
mypy: error: Unexpected keyword argument "font" for "configure" of "Misc" [call-arg]pylance: No parameter named "font"
What is the fix for this? I cannot find a reference what is actually supported as kw arguments and what the correct would be to change the font.
tkinteris a thin wrapper overtcl/tk(a weakly typed language) which is whytkintercan't really be strongly typed. I don't know much aboutmypynorpylancebut I would suggest that you disable the static type checking aroundtkintercodeevent.widgetis, so how can you be sure that it has thefontattribute? Sinceset_font_cb()is a method of attk.Frameclass,event.widgetmay be most probably an instance ofttk.Framewhich does not havefontattribute.