Implement a base pattern for listers with no state storage

This commit is contained in:
Nicolas Dandrimont 2020-12-07 18:12:15 +01:00
parent b63aa83b41
commit 734901747b
2 changed files with 60 additions and 0 deletions

View file

@ -258,3 +258,13 @@ class Lister(Generic[StateType, PageType]):
"""
config = load_from_envvar()
return cls.from_config(**config, **kwargs)
class StatelessLister(Lister[None, PageType], Generic[PageType]):
def state_from_dict(self, d: BackendStateType) -> None:
"""Always return empty state"""
return None
def state_to_dict(self, state: None) -> BackendStateType:
"""Always set empty state"""
return {}