fix(types): correct type-ignore codes and narrow Optional in tests

CI mypy (not run locally before) flagged the is_not() ignores as
union-attr and the un-narrowed RSSItem | None in the re-enable test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019WTfJZ3EzCpY8SLhzXT6Sf
This commit is contained in:
Estrella Pan
2026-07-26 15:53:14 +02:00
parent f54df55754
commit 5cc2fabc64
2 changed files with 4 additions and 2 deletions

View File

@@ -567,11 +567,11 @@ class BangumiDatabase:
from module.models.torrent import Torrent
await self.session.execute(
delete(Torrent).where(Torrent.bangumi_id.is_not(None)) # type: ignore[attr-defined]
delete(Torrent).where(Torrent.bangumi_id.is_not(None)) # type: ignore[union-attr]
)
await self.session.execute(
update(Aria2Gid)
.where(Aria2Gid.bangumi_id.is_not(None)) # type: ignore[attr-defined]
.where(Aria2Gid.bangumi_id.is_not(None)) # type: ignore[union-attr]
.values(bangumi_id=None)
)
await self.session.execute(delete(Bangumi))

View File

@@ -119,10 +119,12 @@ async def test_rss_add_reenables_disabled_duplicate(db_session):
await db.add(RSSItem(url=rss_url, name="Test RSS"))
item = await db.search_url(rss_url)
assert item is not None
await db.disable(item.id)
assert await db.add(RSSItem(url=rss_url, name="Test RSS")) is True
item = await db.search_url(rss_url)
assert item is not None
assert item.enabled is True