fix ide warnings

This commit is contained in:
jxxghp
2024-12-23 16:58:04 +08:00
parent baa48610ea
commit 61d7374d95
21 changed files with 71 additions and 78 deletions
+1 -2
View File
@@ -19,8 +19,7 @@ from app.helper.directory import DirectoryHelper
from app.helper.message import MessageHelper from app.helper.message import MessageHelper
from app.helper.torrent import TorrentHelper from app.helper.torrent import TorrentHelper
from app.log import logger from app.log import logger
from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent, Notification from app.schemas import ExistMediaInfo, NotExistMediaInfo, DownloadingTorrent, Notification, ResourceSelectionEventData, ResourceDownloadEventData
from app.schemas.event import ResourceSelectionEventData, ResourceDownloadEventData
from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType, ChainEventType from app.schemas.types import MediaType, TorrentStatus, EventType, MessageChannel, NotificationType, ChainEventType
from app.utils.http import RequestUtils from app.utils.http import RequestUtils
from app.utils.string import StringUtils from app.utils.string import StringUtils
+1 -1
View File
@@ -7,7 +7,7 @@ from app.core.security import get_password_hash, verify_password
from app.db.models.user import User from app.db.models.user import User
from app.db.user_oper import UserOper from app.db.user_oper import UserOper
from app.log import logger from app.log import logger
from app.schemas.event import AuthCredentials, AuthInterceptCredentials from app.schemas import AuthCredentials, AuthInterceptCredentials
from app.schemas.types import ChainEventType from app.schemas.types import ChainEventType
from app.utils.otp import OtpUtils from app.utils.otp import OtpUtils
from app.utils.singleton import Singleton from app.utils.singleton import Singleton
+1 -2
View File
@@ -15,8 +15,7 @@ from app.helper.message import MessageHelper
from app.helper.thread import ThreadHelper from app.helper.thread import ThreadHelper
from app.log import logger from app.log import logger
from app.scheduler import Scheduler from app.scheduler import Scheduler
from app.schemas import Notification from app.schemas import Notification, CommandRegisterEventData
from app.schemas.event import CommandRegisterEventData
from app.schemas.types import EventType, MessageChannel, ChainEventType from app.schemas.types import EventType, MessageChannel, ChainEventType
from app.utils.object import ObjectUtils from app.utils.object import ObjectUtils
from app.utils.singleton import Singleton from app.utils.singleton import Singleton
+1 -1
View File
@@ -13,7 +13,7 @@ from typing import Callable, Dict, List, Optional, Union
from app.helper.message import MessageHelper from app.helper.message import MessageHelper
from app.helper.thread import ThreadHelper from app.helper.thread import ThreadHelper
from app.log import logger from app.log import logger
from app.schemas.event import ChainEventData from app.schemas import ChainEventData
from app.schemas.types import ChainEventType, EventType from app.schemas.types import ChainEventType, EventType
from app.utils.limit import ExponentialBackoffRateLimiter from app.utils.limit import ExponentialBackoffRateLimiter
from app.utils.singleton import Singleton from app.utils.singleton import Singleton
+4 -4
View File
@@ -13,7 +13,7 @@ connect_args = {
# 启用 WAL 模式时的额外配置 # 启用 WAL 模式时的额外配置
if settings.DB_WAL_ENABLE: if settings.DB_WAL_ENABLE:
connect_args["check_same_thread"] = False connect_args["check_same_thread"] = False
kwargs = { db_kwargs = {
"url": f"sqlite:///{settings.CONFIG_PATH}/user.db", "url": f"sqlite:///{settings.CONFIG_PATH}/user.db",
"pool_pre_ping": settings.DB_POOL_PRE_PING, "pool_pre_ping": settings.DB_POOL_PRE_PING,
"echo": settings.DB_ECHO, "echo": settings.DB_ECHO,
@@ -23,13 +23,13 @@ kwargs = {
} }
# 当使用 QueuePool 时,添加 QueuePool 特有的参数 # 当使用 QueuePool 时,添加 QueuePool 特有的参数
if pool_class == QueuePool: if pool_class == QueuePool:
kwargs.update({ db_kwargs.update({
"pool_size": settings.DB_POOL_SIZE, "pool_size": settings.DB_POOL_SIZE,
"pool_timeout": settings.DB_POOL_TIMEOUT, "pool_timeout": settings.DB_POOL_TIMEOUT,
"max_overflow": settings.DB_MAX_OVERFLOW "max_overflow": settings.DB_MAX_OVERFLOW
}) })
# 创建数据库引擎 # 创建数据库引擎
Engine = create_engine(**kwargs) Engine = create_engine(**db_kwargs)
# 根据配置设置日志模式 # 根据配置设置日志模式
journal_mode = "WAL" if settings.DB_WAL_ENABLE else "DELETE" journal_mode = "WAL" if settings.DB_WAL_ENABLE else "DELETE"
with Engine.connect() as connection: with Engine.connect() as connection:
@@ -198,7 +198,7 @@ class Base:
@classmethod @classmethod
@db_query @db_query
def get(cls, db: Session, rid: int) -> Self: def get(cls, db: Session, rid: int) -> Self:
return db.query(cls).filter(cls.id == rid).first() return db.query(cls).filter(and_(cls.id == rid)).first()
@db_update @db_update
def update(self, db: Session, payload: dict): def update(self, db: Session, payload: dict):
-1
View File
@@ -1,5 +1,4 @@
from datetime import datetime from datetime import datetime
from functools import lru_cache
import requests import requests
from cachetools import TTLCache, cached from cachetools import TTLCache, cached
+5 -6
View File
@@ -6,7 +6,6 @@ from app.core.event import eventmanager
from app.log import logger from app.log import logger
from app.modules import _MediaServerBase, _ModuleBase from app.modules import _MediaServerBase, _ModuleBase
from app.modules.emby.emby import Emby from app.modules.emby.emby import Emby
from app.schemas.event import AuthCredentials, AuthInterceptCredentials
from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType
@@ -73,8 +72,8 @@ class EmbyModule(_ModuleBase, _MediaServerBase[Emby]):
logger.info(f"Emby服务器 {name} 连接断开,尝试重连 ...") logger.info(f"Emby服务器 {name} 连接断开,尝试重连 ...")
server.reconnect() server.reconnect()
def user_authenticate(self, credentials: AuthCredentials, service_name: Optional[str] = None) \ def user_authenticate(self, credentials: schemas.AuthCredentials, service_name: Optional[str] = None) \
-> Optional[AuthCredentials]: -> Optional[schemas.AuthCredentials]:
""" """
使用Emby用户辅助完成用户认证 使用Emby用户辅助完成用户认证
:param credentials: 认证数据 :param credentials: 认证数据
@@ -96,11 +95,11 @@ class EmbyModule(_ModuleBase, _MediaServerBase[Emby]):
# 触发认证拦截事件 # 触发认证拦截事件
intercept_event = eventmanager.send_event( intercept_event = eventmanager.send_event(
etype=ChainEventType.AuthIntercept, etype=ChainEventType.AuthIntercept,
data=AuthInterceptCredentials(username=credentials.username, channel=self.get_name(), data=schemas.AuthInterceptCredentials(username=credentials.username, channel=self.get_name(),
service=name, status="triggered") service=name, status="triggered")
) )
if intercept_event and intercept_event.event_data: if intercept_event and intercept_event.event_data:
intercept_data: AuthInterceptCredentials = intercept_event.event_data intercept_data: schemas.AuthInterceptCredentials = intercept_event.event_data
if intercept_data.cancel: if intercept_data.cancel:
continue continue
token = server.authenticate(credentials.username, credentials.password) token = server.authenticate(credentials.username, credentials.password)
+1 -2
View File
@@ -16,8 +16,7 @@ from app.helper.module import ModuleHelper
from app.log import logger from app.log import logger
from app.modules import _ModuleBase from app.modules import _ModuleBase
from app.modules.filemanager.storages import StorageBase from app.modules.filemanager.storages import StorageBase
from app.schemas import TransferInfo, ExistMediaInfo, TmdbEpisode, TransferDirectoryConf, FileItem, StorageUsage from app.schemas import TransferInfo, ExistMediaInfo, TmdbEpisode, TransferDirectoryConf, FileItem, StorageUsage, TransferRenameEventData
from app.schemas.event import TransferRenameEventData
from app.schemas.types import MediaType, ModuleType, ChainEventType, OtherModulesType from app.schemas.types import MediaType, ModuleType, ChainEventType, OtherModulesType
from app.utils.system import SystemUtils from app.utils.system import SystemUtils
+1 -1
View File
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from pathlib import Path from pathlib import Path
from typing import Optional, List, Union, Dict, Tuple from typing import Optional, List, Dict, Tuple
from app import schemas from app import schemas
from app.helper.storage import StorageHelper from app.helper.storage import StorageHelper
+1 -1
View File
@@ -282,6 +282,6 @@ class IndexerModule(_ModuleBase):
leeching_size=site_obj.leeching_size, leeching_size=site_obj.leeching_size,
message_unread=site_obj.message_unread, message_unread=site_obj.message_unread,
message_unread_contents=site_obj.message_unread_contents or [], message_unread_contents=site_obj.message_unread_contents or [],
updated_at=datetime.now().strftime('%Y-%m-%d'), updated_day=datetime.now().strftime('%Y-%m-%d'),
err_msg=site_obj.err_msg err_msg=site_obj.err_msg
) )
+1 -1
View File
@@ -675,7 +675,7 @@ class TorrentSpider:
elif method_name == "appendleft": elif method_name == "appendleft":
text = f"{args}{text}" text = f"{args}{text}"
elif method_name == "querystring": elif method_name == "querystring":
parsed_url = urlparse(text) parsed_url = urlparse(str(text))
query_params = parse_qs(parsed_url.query) query_params = parse_qs(parsed_url.query)
param_value = query_params.get(args) param_value = query_params.get(args)
text = param_value[0] if param_value else '' text = param_value[0] if param_value else ''
+1 -1
View File
@@ -6,7 +6,7 @@ from app.core.event import eventmanager
from app.log import logger from app.log import logger
from app.modules import _MediaServerBase, _ModuleBase from app.modules import _MediaServerBase, _ModuleBase
from app.modules.jellyfin.jellyfin import Jellyfin from app.modules.jellyfin.jellyfin import Jellyfin
from app.schemas.event import AuthCredentials, AuthInterceptCredentials from app.schemas import AuthCredentials, AuthInterceptCredentials
from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType
+1 -1
View File
@@ -6,7 +6,7 @@ from app.core.event import eventmanager
from app.log import logger from app.log import logger
from app.modules import _ModuleBase, _MediaServerBase from app.modules import _ModuleBase, _MediaServerBase
from app.modules.plex.plex import Plex from app.modules.plex.plex import Plex
from app.schemas.event import AuthCredentials, AuthInterceptCredentials from app.schemas import AuthCredentials, AuthInterceptCredentials
from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType from app.schemas.types import MediaType, ModuleType, ChainEventType, MediaServerType
+1 -2
View File
@@ -7,8 +7,7 @@ from app.core.event import eventmanager
from app.log import logger from app.log import logger
from app.modules import _ModuleBase, _MessageBase from app.modules import _ModuleBase, _MessageBase
from app.modules.telegram.telegram import Telegram from app.modules.telegram.telegram import Telegram
from app.schemas import MessageChannel, CommingMessage, Notification from app.schemas import MessageChannel, CommingMessage, Notification, CommandRegisterEventData
from app.schemas.event import CommandRegisterEventData
from app.schemas.types import ModuleType, ChainEventType from app.schemas.types import ModuleType, ChainEventType
from app.utils.structures import DictUtils from app.utils.structures import DictUtils
+1 -2
View File
@@ -8,8 +8,7 @@ from app.log import logger
from app.modules import _ModuleBase, _MessageBase from app.modules import _ModuleBase, _MessageBase
from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt from app.modules.wechat.WXBizMsgCrypt3 import WXBizMsgCrypt
from app.modules.wechat.wechat import WeChat from app.modules.wechat.wechat import WeChat
from app.schemas import MessageChannel, CommingMessage, Notification from app.schemas import MessageChannel, CommingMessage, Notification, CommandRegisterEventData
from app.schemas.event import CommandRegisterEventData
from app.schemas.types import ModuleType, ChainEventType from app.schemas.types import ModuleType, ChainEventType
from app.utils.dom import DomUtils from app.utils.dom import DomUtils
from app.utils.structures import DictUtils from app.utils.structures import DictUtils
+1
View File
@@ -18,3 +18,4 @@ from .system import *
from .file import * from .file import *
from .exception import * from .exception import *
from .system import * from .system import *
from .event import *
+1 -1
View File
@@ -89,7 +89,7 @@ class AuthInterceptCredentials(ChainEventData):
channel: str = Field(..., description="认证渠道") channel: str = Field(..., description="认证渠道")
service: str = Field(..., description="服务名称") service: str = Field(..., description="服务名称")
status: str = Field(..., description="认证状态, 包含 'triggered' 表示认证触发,'completed' 表示认证成功") status: str = Field(..., description="认证状态, 包含 'triggered' 表示认证触发,'completed' 表示认证成功")
token: Optional[str] = Field(None, description="认证令牌") token: Optional[str] = Field(default=None, description="认证令牌")
# 输出参数 # 输出参数
source: str = Field(default="未知拦截源", description="拦截源") source: str = Field(default="未知拦截源", description="拦截源")
+1 -1
View File
@@ -132,7 +132,7 @@ class MediaServerSeasonInfo(BaseModel):
媒体服务器媒体剧集信息 媒体服务器媒体剧集信息
""" """
season: Optional[int] = None season: Optional[int] = None
episodes: Optional[List[int]] = Field(default_factory=list) episodes: Optional[List[Dict[int, list]]] = Field(default_factory=list)
class WebhookEventInfo(BaseModel): class WebhookEventInfo(BaseModel):
+40 -38
View File
@@ -3,55 +3,57 @@ from pydantic import BaseModel, Field
class RadarrMovie(BaseModel): class RadarrMovie(BaseModel):
id: Optional[int] id: Optional[int] = None
title: Optional[str] title: Optional[str] = None
year: Optional[str] year: Optional[str] = None
isAvailable: bool = False isAvailable: bool = False
monitored: bool = False monitored: bool = False
tmdbId: Optional[int] tmdbId: Optional[int] = None
imdbId: Optional[str] imdbId: Optional[str] = None
titleSlug: Optional[str] titleSlug: Optional[str] = None
folderName: Optional[str] folderName: Optional[str] = None
path: Optional[str] path: Optional[str] = None
profileId: Optional[int] profileId: Optional[int] = None
qualityProfileId: Optional[int] qualityProfileId: Optional[int] = None
added: Optional[str] added: Optional[str] = None
hasFile: bool = False hasFile: bool = False
class SonarrSeries(BaseModel): class SonarrSeries(BaseModel):
id: Optional[int] id: Optional[int] = None
title: Optional[str] title: Optional[str] = None
sortTitle: Optional[str] sortTitle: Optional[str] = None
seasonCount: Optional[int] seasonCount: Optional[int] = None
status: Optional[str] status: Optional[str] = None
overview: Optional[str] overview: Optional[str] = None
network: Optional[str] network: Optional[str] = None
airTime: Optional[str] airTime: Optional[str] = None
images: list = Field(default_factory=list) images: list = Field(default_factory=list)
remotePoster: Optional[str] remotePoster: Optional[str] = None
seasons: list = Field(default_factory=list) seasons: list = Field(default_factory=list)
year: Optional[str] year: Optional[str] = None
path: Optional[str] path: Optional[str] = None
profileId: Optional[int] profileId: Optional[int] = None
languageProfileId: Optional[int] languageProfileId: Optional[int] = None
seasonFolder: bool = False seasonFolder: bool = False
monitored: bool = False monitored: bool = False
useSceneNumbering: bool = False useSceneNumbering: bool = False
runtime: Optional[int] runtime: Optional[int] = None
tmdbId: Optional[int] tmdbId: Optional[int] = None
imdbId: Optional[str] imdbId: Optional[str] = None
tvdbId: Optional[int] tvdbId: Optional[int] = None
tvRageId: Optional[int] tvRageId: Optional[int] = None
tvMazeId: Optional[int] tvMazeId: Optional[int] = None
firstAired: Optional[str] firstAired: Optional[str] = None
seriesType: Optional[str] seriesType: Optional[str] = None
cleanTitle: Optional[str] cleanTitle: Optional[str] = None
titleSlug: Optional[str] titleSlug: Optional[str] = None
certification: Optional[str] certification: Optional[str] = None
genres: list = Field(default_factory=list) genres: list = Field(default_factory=list)
tags: list = Field(default_factory=list) tags: list = Field(default_factory=list)
added: Optional[str] added: Optional[str] = None
ratings: Optional[dict] ratings: Optional[dict] = None
qualityProfileId: Optional[int] qualityProfileId: Optional[int] = None
statistics: dict = Field(default_factory=dict) statistics: dict = Field(default_factory=dict)
isAvailable: Optional[bool] = False
hasFile: Optional[bool] = False
+7 -7
View File
@@ -53,7 +53,7 @@ class Site(BaseModel):
class SiteStatistic(BaseModel): class SiteStatistic(BaseModel):
# 站点ID # 站点ID
domain: Optional[str] domain: Optional[str] = None
# 成功次数 # 成功次数
success: Optional[int] = 0 success: Optional[int] = 0
# 失败次数 # 失败次数
@@ -63,7 +63,7 @@ class SiteStatistic(BaseModel):
# 最后状态 # 最后状态
lst_state: Optional[int] = 0 lst_state: Optional[int] = 0
# 最后修改时间 # 最后修改时间
lst_mod_date: Optional[str] lst_mod_date: Optional[str] = None
# 备注 # 备注
note: Optional[Any] = None note: Optional[Any] = None
@@ -73,15 +73,15 @@ class SiteStatistic(BaseModel):
class SiteUserData(BaseModel): class SiteUserData(BaseModel):
# 站点域名 # 站点域名
domain: Optional[str] domain: Optional[str] = None
# 用户名 # 用户名
username: Optional[str] username: Optional[str] = None
# 用户ID # 用户ID
userid: Optional[Union[int, str]] userid: Optional[Union[int, str]] = None
# 用户等级 # 用户等级
user_level: Optional[str] user_level: Optional[str] = None
# 加入时间 # 加入时间
join_at: Optional[str] join_at: Optional[str] = None
# 积分 # 积分
bonus: Optional[float] = 0.0 bonus: Optional[float] = 0.0
# 上传量 # 上传量
-3
View File
@@ -5,9 +5,6 @@ Revises: ecf3c693fdf3
Create Date: 2024-11-14 12:49:13.838120 Create Date: 2024-11-14 12:49:13.838120
""" """
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import sqlite
from app.db.systemconfig_oper import SystemConfigOper from app.db.systemconfig_oper import SystemConfigOper
from app.schemas.types import SystemConfigKey from app.schemas.types import SystemConfigKey