Skip to content

Commit 1ee8764

Browse files
committed
🚨 style: fix lint errors
1 parent e67ba7d commit 1ee8764

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/yutto/cli/settings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import platform
55
import sys
66
from pathlib import Path
7-
from typing import Annotated, Any, Literal, Optional
7+
from typing import Annotated, Any, Literal
88

99
from pydantic import BaseModel, Field
1010

@@ -36,7 +36,7 @@ class YuttoBasicSettings(BaseModel):
3636
audio_quality: Annotated[AudioQuality, Field(30251)]
3737
vcodec: Annotated[str, Field("avc:copy")]
3838
acodec: Annotated[str, Field("mp4a:copy")]
39-
download_vcodec_priority: Annotated[Optional[list[str]], Field(None)] # noqa: UP007
39+
download_vcodec_priority: Annotated[list[str] | None, Field(None)]
4040
output_format: Annotated[Literal["infer", "mp4", "mkv", "mov"], Field("infer")]
4141
output_format_audio_only: Annotated[
4242
Literal["infer", "m4a", "aac", "mp3", "flac", "mp4", "mkv", "mov"], Field("infer")
@@ -46,13 +46,13 @@ class YuttoBasicSettings(BaseModel):
4646
overwrite: Annotated[bool, Field(False)]
4747
proxy: Annotated[str, Field("auto")]
4848
dir: Annotated[str, Field("./")]
49-
tmp_dir: Annotated[Optional[str], Field(None)] # noqa: UP007
49+
tmp_dir: Annotated[str | None, Field(None)]
5050
sessdata: Annotated[str, Field("")]
5151
subpath_template: Annotated[str, Field("{auto}")]
5252
aliases: Annotated[dict[str, str], Field(dict[str, str]())]
5353
metadata_format_premiered: Annotated[str, Field(TIME_DATE_FMT)]
5454
download_interval: Annotated[int, Field(0)]
55-
banned_mirrors_pattern: Annotated[Optional[str], Field(None)] # noqa: UP007
55+
banned_mirrors_pattern: Annotated[str | None, Field(None)]
5656
vip_strict: Annotated[bool, Field(False)]
5757
login_strict: Annotated[bool, Field(False)]
5858
no_color: Annotated[bool, Field(False)]
@@ -72,7 +72,7 @@ class YuttoResourceSettings(BaseModel):
7272

7373

7474
class YuttoDanmakuSettings(BaseModel):
75-
font_size: Annotated[Optional[int], Field(None)] # noqa: UP007
75+
font_size: Annotated[int | None, Field(None)]
7676
font: Annotated[str, Field("SimHei")]
7777
opacity: Annotated[float, Field(0.8)]
7878
display_region_ratio: Annotated[float, Field(1.0)]
@@ -89,8 +89,8 @@ class YuttoDanmakuSettings(BaseModel):
8989

9090
class YuttoBatchSettings(BaseModel):
9191
with_section: Annotated[bool, Field(False)]
92-
batch_filter_start_time: Annotated[Optional[str], Field(None)] # noqa: UP007
93-
batch_filter_end_time: Annotated[Optional[str], Field(None)] # noqa: UP007
92+
batch_filter_start_time: Annotated[str | None, Field(None)]
93+
batch_filter_end_time: Annotated[str | None, Field(None)]
9494

9595

9696
class YuttoSettings(BaseModel):

src/yutto/mcp.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import AsyncIterator
44
from contextlib import asynccontextmanager
55
from dataclasses import dataclass
6-
from typing import TYPE_CHECKING, cast
6+
from typing import TYPE_CHECKING, Any
77

88
from fastmcp import Context, FastMCP
99
from pydantic import Field
@@ -13,6 +13,7 @@
1313

1414
if TYPE_CHECKING:
1515
from mcp.server.session import ServerSession
16+
from mcp.shared.context import RequestContext
1617

1718

1819
@dataclass
@@ -47,15 +48,15 @@ def parse_args(url: str, dir: str):
4748

4849
@mcp.tool()
4950
async def add_task(
50-
ctx: Context, # pyright: ignore[reportMissingTypeArgument, reportUnknownParameterType]
51+
ctx: Context,
5152
url: str = Field(description="The URL to download, you can also use a short link like 'BV1CrfKYLEeP'"),
5253
dir: str = Field(description="The directory to save the downloaded file"),
5354
) -> str:
5455
"""
5556
Use this tool to download a video from Bilibili using the given URL or short link.
5657
"""
57-
ctx_typed = cast("Context[ServerSession, AppContext]", ctx)
58-
download_manager: DownloadManager = ctx_typed.request_context.lifespan_context.download_manager
58+
request_context: RequestContext[ServerSession, AppContext, Any] = ctx.request_context # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType]
59+
download_manager: DownloadManager = request_context.lifespan_context.download_manager
5960
await download_manager.add_task(DownloadTask(args=parse_args(url, dir)))
6061
return "Task added"
6162

src/yutto/utils/fetcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async def fetch_text(
145145
Logger.debug(f"Fetch text: {url}")
146146
Logger.status.next_tick()
147147
resp = await client.get(url, params=params)
148-
if resp.status_code != httpx.codes.OK:
148+
if not resp.is_success:
149149
return None
150150
return resp.text
151151

@@ -162,7 +162,7 @@ async def fetch_bin(
162162
Logger.debug(f"Fetch bin: {url}")
163163
Logger.status.next_tick()
164164
resp = await client.get(url, params=params)
165-
if resp.status_code != httpx.codes.OK:
165+
if not resp.is_success:
166166
return None
167167
return resp.read()
168168

@@ -179,7 +179,7 @@ async def fetch_json(
179179
Logger.debug(f"Fetch json: {url}")
180180
Logger.status.next_tick()
181181
resp = await client.get(url, params=params)
182-
if resp.status_code != httpx.codes.OK:
182+
if not resp.is_success:
183183
return None
184184
return resp.json()
185185

0 commit comments

Comments
 (0)