2 ms·
list[int | str] might usually be a mistake, but what about my_list = [BarWidget(...), FooWidget(...)] ? my_list.append(BazWidget(...)) my_list.append(7) Wou
by dmurray 1y ago
list[int | str] might usually be a mistake, but what about
my_list = [BarWidget(...), FooWidget(...)] ?
my_list.append(BazWidget(...))
my_list.append(7)
Wouldn't it be nice if the type checker could infer the type hint there, which is almost certainly intended to be list[Widget], and allow the first append and flag the second one?