-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
With this code:
def func(w: tk.Widget) -> Any:
return w.cget()
Mypy output is:
error: "Widget" has no attribute "cget"
I think that Misc should have a generic definition of cget() .
Something like this::
def cget(self, key: str) -> Any: ...
I tried this change and got no problem.
This case, indeed, is problematic:
def func(w: Union[tk.Widget,tk.Toplevel,tk.Tk]) -> str:
return w.cget('cursor')
Mypy output:
error: Cannot determine type of 'cget'
The workaround:
def func(w: Union[tk.Widget, tk.Toplevel, tk.Tk]) -> str:
w = cast(tk.Widget, w)
return w.cget('cursor')
.configure has the same problem, but is more hard to fix.
Metadata
Metadata
Assignees
Labels
No labels