You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type dict[str, checkbox] cannot be assigned to parameter elements of type dict[str, UIElement[Any, Any]] ... Consider switching from dict to Mapping.
Why this is problematic
Runtime behavior is correct.
Users must add casts like cast(dict[str, Any], elements).
UIElement appears internal/non-public, so precise public typing is hard to express externally.
Proposed fix
Use a covariant input type for constructor parameter, e.g.:
changed the title [-]Typing: ui.dictionary.__init__ uses invariant dict[UIElement] and rejects dict[str, ui.checkbox][/-][+]Typing: ui.dictionary.__init__ uses invariant dict[str, UIElement] and rejects dict[str, ui.checkbox][/+]on Aug 23, 2026
I'd like to take this on. Plan: change dictionary.__init__'s elements param to Mapping[str, UIElement[Any, Any]], do the same for validate_and_clone's input parameter (keeping its return type as dict since it builds a fresh one), and apply the same covariant-input fix to ui.batch. Will open a PR with tests shortly.
Activity
[-]Typing: ui.dictionary.__init__ uses invariant dict[UIElement] and rejects dict[str, ui.checkbox][/-][+]Typing: ui.dictionary.__init__ uses invariant dict[str, UIElement] and rejects dict[str, ui.checkbox][/+]Light2Dark commentedon Aug 24, 2026
We'd be happy to accept a contribution. You may also want to look at updating the function below too.
ui.batch also has the same issue, you may want to do a pass on similar elements like dictionary
roridemonslayer commentedon Aug 26, 2026
I'd like to take this on. Plan: change
dictionary.__init__'selementsparam toMapping[str, UIElement[Any, Any]], do the same forvalidate_and_clone's input parameter (keeping its return type asdictsince it builds a fresh one), and apply the same covariant-input fix toui.batch. Will open a PR with tests shortly.