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
In #2004, the return type of ListFilter.choices was changed to use a private TypedDict. However, since TypedDict is not a subclass of dict, this introduces extra friction when implementing a new SimpleListFilter. For example, this example will fail since dict cannot be used in place of _ListFilterChoices:
class ExampleFilter(SimpleListFilter):
...
def choices(self, changelist: ChangeList) -> Iterator[dict]:
for lookup, title in self.lookup_choices:
yield {
"selected": self.value() == lookup,
"query_string": changelist.get_query_string(
{self.parameter_name: lookup}
),
"display": title.upper(),
}
As a workaround, the application developer can of course either duplicate _ListFilterChoices locally, or use Any, but either isn't very ergonomic to my eyes.
The text was updated successfully, but these errors were encountered:
Hello!
In #2004, the return type of
ListFilter.choices
was changed to use a privateTypedDict
. However, sinceTypedDict
is not a subclass ofdict
, this introduces extra friction when implementing a newSimpleListFilter
. For example, this example will fail sincedict
cannot be used in place of_ListFilterChoices
:As a workaround, the application developer can of course either duplicate
_ListFilterChoices
locally, or useAny
, but either isn't very ergonomic to my eyes.The text was updated successfully, but these errors were encountered: