core: improvements for warnings, twitter/rss: try using @warn_if_empty

This commit is contained in:
Dima Gerasimov 2020-05-25 00:56:03 +01:00
parent 616ffb457e
commit 216944b3cd
5 changed files with 35 additions and 17 deletions

View file

@ -17,6 +17,8 @@ from typing import Iterable, Tuple, Sequence
SubscriptionState = Tuple[datetime, Sequence[Subscription]]
from ..core import warn_if_empty
@warn_if_empty
def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscription]:
"""
Keeps track of everything I ever subscribed to.
@ -34,6 +36,9 @@ def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscri
if feed.url not in by_url:
by_url[feed.url] = feed
if len(states) == 0:
return []
_, last_state = max(states, key=lambda x: x[0])
last_urls = {f.url for f in last_state}