general: migrate modules to use 3.9 features
This commit is contained in:
parent
d3f9a8e8b6
commit
d915c848e9
125 changed files with 889 additions and 739 deletions
|
@ -3,9 +3,9 @@ Unified RSS data, merged from different services I used historically
|
|||
'''
|
||||
|
||||
# NOTE: you can comment out the sources you're not using
|
||||
from . import feedbin, feedly
|
||||
from collections.abc import Iterable
|
||||
|
||||
from typing import Iterable
|
||||
from . import feedbin, feedly
|
||||
from .common import Subscription, compute_subscriptions
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from my.core import __NOT_HPI_MODULE__
|
||||
from __future__ import annotations
|
||||
|
||||
from my.core import __NOT_HPI_MODULE__ # isort: skip
|
||||
|
||||
from collections.abc import Iterable, Sequence
|
||||
from dataclasses import dataclass, replace
|
||||
from itertools import chain
|
||||
from typing import Optional, List, Dict, Iterable, Tuple, Sequence
|
||||
|
||||
from my.core import warn_if_empty, datetime_aware
|
||||
from my.core import datetime_aware, warn_if_empty
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -13,16 +15,16 @@ class Subscription:
|
|||
url: str
|
||||
id: str # TODO not sure about it...
|
||||
# eh, not all of them got reasonable 'created' time
|
||||
created_at: Optional[datetime_aware]
|
||||
created_at: datetime_aware | None
|
||||
subscribed: bool = True
|
||||
|
||||
|
||||
# snapshot of subscriptions at time
|
||||
SubscriptionState = Tuple[datetime_aware, Sequence[Subscription]]
|
||||
SubscriptionState = tuple[datetime_aware, Sequence[Subscription]]
|
||||
|
||||
|
||||
@warn_if_empty
|
||||
def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscription]:
|
||||
def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> list[Subscription]:
|
||||
"""
|
||||
Keeps track of everything I ever subscribed to.
|
||||
In addition, keeps track of unsubscribed as well (so you'd remember when and why you unsubscribed)
|
||||
|
@ -30,7 +32,7 @@ def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscri
|
|||
states = list(chain.from_iterable(sources))
|
||||
# TODO keep 'source'/'provider'/'service' attribute?
|
||||
|
||||
by_url: Dict[str, Subscription] = {}
|
||||
by_url: dict[str, Subscription] = {}
|
||||
# ah. dates are used for sorting
|
||||
for _when, state in sorted(states):
|
||||
# TODO use 'when'?
|
||||
|
|
|
@ -3,15 +3,15 @@ Feedbin RSS reader
|
|||
"""
|
||||
|
||||
import json
|
||||
from collections.abc import Iterator, Sequence
|
||||
from pathlib import Path
|
||||
from typing import Iterator, Sequence
|
||||
|
||||
from my.core import get_files, stat, Stats
|
||||
from my.core import Stats, get_files, stat
|
||||
from my.core.compat import fromisoformat
|
||||
|
||||
from .common import Subscription, SubscriptionState
|
||||
|
||||
from my.config import feedbin as config
|
||||
|
||||
from my.config import feedbin as config # isort: skip
|
||||
|
||||
def inputs() -> Sequence[Path]:
|
||||
return get_files(config.export_path)
|
||||
|
|
|
@ -4,9 +4,10 @@ Feedly RSS reader
|
|||
|
||||
import json
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Iterator, Sequence
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Iterator, Protocol, Sequence
|
||||
from typing import Protocol
|
||||
|
||||
from my.core import Paths, get_files
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue