From 86ae5eac214140b1b2ba196b65168414fb693768 Mon Sep 17 00:00:00 2001 From: TheOnlyWayUp Date: Mon, 9 Jun 2025 22:06:05 +0000 Subject: [PATCH] api: Update typehints --- src/api/src/create_book/create_book.py | 4 ++-- src/api/src/create_book/models.py | 6 +++--- src/api/src/create_book/utils.py | 6 ------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/api/src/create_book/create_book.py b/src/api/src/create_book/create_book.py index ca7f362..b69ae93 100644 --- a/src/api/src/create_book/create_book.py +++ b/src/api/src/create_book/create_book.py @@ -1,7 +1,7 @@ from __future__ import annotations from io import BytesIO -from typing import Optional, Tuple +from typing import Optional import backoff from aiohttp import ClientResponseError @@ -63,7 +63,7 @@ async def fetch_cookies(username: str, password: str) -> dict: @backoff.on_exception(backoff.expo, ClientResponseError, max_time=15) async def fetch_story_from_partId( part_id: int, cookies: Optional[dict] = None -) -> Tuple[int, Story]: +) -> tuple[int, Story]: """Fetch Story metadata from a Part ID.""" with start_action(action_type="api_fetch_storyFromPartId"): async with CachedSession( diff --git a/src/api/src/create_book/models.py b/src/api/src/create_book/models.py index 7124513..53ef697 100644 --- a/src/api/src/create_book/models.py +++ b/src/api/src/create_book/models.py @@ -1,4 +1,4 @@ -from typing import List, Optional, TypedDict +from typing import Optional, TypedDict class CopyrightData(TypedDict): @@ -34,9 +34,9 @@ class Story(TypedDict): description: str cover: str completed: bool - tags: List[str] + tags: list[str] mature: bool url: str - parts: List[Part] + parts: list[Part] isPaywalled: bool copyright: int diff --git a/src/api/src/create_book/utils.py b/src/api/src/create_book/utils.py index 83ccdfc..b2d67fd 100644 --- a/src/api/src/create_book/utils.py +++ b/src/api/src/create_book/utils.py @@ -1,11 +1,5 @@ import re import unicodedata -from typing import cast - -import bs4 -from bs4 import BeautifulSoup - -from .models import Part def slugify(value, allow_unicode=False) -> str: