Open
Description
Hello!
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.
Metadata
Metadata
Assignees
Labels
No labels