From 446f70ee3e9b0c00a25d2f9c2dc55c29188ede6f Mon Sep 17 00:00:00 2001 From: "Aliaksei Yaletski (Tiendil)" Date: Fri, 27 Dec 2024 16:13:29 +0100 Subject: [PATCH] typing --- ffun/ffun/cli/commands/estimates.py | 8 +++++--- ffun/ffun/loader/domain.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ffun/ffun/cli/commands/estimates.py b/ffun/ffun/cli/commands/estimates.py index 2f2be66f..d8272569 100644 --- a/ffun/ffun/cli/commands/estimates.py +++ b/ffun/ffun/cli/commands/estimates.py @@ -6,7 +6,7 @@ from ffun.application.application import with_app from ffun.core import logging from ffun.domain.entities import CollectionId, FeedUrl, UnknownUrl -from ffun.domain.urls import normalize_classic_unknown_url +from ffun.domain.urls import normalize_classic_unknown_url, to_feed_url from ffun.feeds_collections.collections import collections from ffun.loader.domain import extract_feed_info @@ -46,7 +46,9 @@ async def run_entries_per_day_for_feed(raw_feed_url: str) -> None: async with with_app(): feed_url = normalize_classic_unknown_url(UnknownUrl(raw_feed_url)) - entries_per_day = await _estimate_entries_per_day(feed_url) + assert feed_url is not None + + entries_per_day = await _estimate_entries_per_day(to_feed_url(feed_url)) logger.info("estimated_entries_for_feed_in_day", feed_url=feed_url, entries_per_day=entries_per_day) @@ -59,7 +61,7 @@ async def run_entries_per_day_for_collection(collection_id: uuid.UUID) -> None: urls = {feed_info.url for feed_info in collection.feeds} - total_entries_per_day = 0 + total_entries_per_day = 0.0 for url in urls: entries_per_day = await _estimate_entries_per_day(url) diff --git a/ffun/ffun/loader/domain.py b/ffun/ffun/loader/domain.py index 0d667854..96946cf4 100644 --- a/ffun/ffun/loader/domain.py +++ b/ffun/ffun/loader/domain.py @@ -92,7 +92,7 @@ async def detect_orphaned(feed_id: FeedId) -> bool: # TODO: tests -async def extract_feed_info(feed_id: FeedId | None, feed_url: str) -> p_entities.FeedInfo | None: +async def extract_feed_info(feed_id: FeedId | None, feed_url: FeedUrl) -> p_entities.FeedInfo | None: try: response = await load_content_with_proxies(feed_url) content = await operations.decode_content(response)