mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-14 02:20:53 +08:00
Merge pull request #311 from 100gle/ci/fix-lint-error
ci: fix lint error
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
[tool.ruff]
|
||||
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
|
||||
select = ["E", "F", "I"]
|
||||
ignore = ['E501']
|
||||
select = [
|
||||
# pycodestyle(E): https://beta.ruff.rs/docs/rules/#pycodestyle-e-w
|
||||
"E",
|
||||
# Pyflakes(F): https://beta.ruff.rs/docs/rules/#pyflakes-f
|
||||
"F",
|
||||
# isort(I): https://beta.ruff.rs/docs/rules/#isort-i
|
||||
"I"
|
||||
]
|
||||
ignore = [
|
||||
# E501: https://beta.ruff.rs/docs/rules/line-too-long/
|
||||
'E501',
|
||||
# F401: https://beta.ruff.rs/docs/rules/unused-import/
|
||||
# avoid unused imports lint in `__init__.py`
|
||||
'F401',
|
||||
]
|
||||
|
||||
# Allow autofix for all enabled rules (when `--fix`) is provided.
|
||||
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
|
||||
|
||||
@@ -2,7 +2,7 @@ from fastapi import Depends, HTTPException, status
|
||||
|
||||
from module.manager import SeasonCollector
|
||||
from module.models import BangumiData
|
||||
from module.models.api import *
|
||||
from module.models.api import RssLink
|
||||
from module.rss import analyser
|
||||
from module.security import get_current_user
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ async def stop(current_user=Depends(get_current_user)):
|
||||
|
||||
|
||||
@router.get("/api/v1/status", tags=["program"])
|
||||
async def status(current_user=Depends(get_current_user)):
|
||||
async def program_status(current_user=Depends(get_current_user)):
|
||||
if not current_user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED, detail="invalid token"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import os.path
|
||||
|
||||
from module.conf import DATA_PATH, settings
|
||||
from module.conf import settings
|
||||
from module.downloader import DownloadClient
|
||||
from module.network import RequestContent
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ try:
|
||||
logger.info("Can't find version info, use DEV_VERSION instead")
|
||||
CONFIG_PATH = "config/config_dev.json"
|
||||
else:
|
||||
CONFIG_PATH = f"config/config.json"
|
||||
CONFIG_PATH = "config/config.json"
|
||||
except ImportError:
|
||||
logger.info("Can't find version info, use DEV_VERSION instead")
|
||||
VERSION = "DEV_VERSION"
|
||||
@@ -38,7 +38,7 @@ class Settings(Config):
|
||||
config = json.load(f)
|
||||
config_obj = Config.parse_obj(config)
|
||||
self.__dict__.update(config_obj.__dict__)
|
||||
logger.info(f"Config loaded")
|
||||
logger.info("Config loaded")
|
||||
|
||||
def save(self, config_dict: dict | None = None):
|
||||
if not config_dict:
|
||||
@@ -75,7 +75,7 @@ class Settings(Config):
|
||||
config_dict[key][attr_name] = self.__val_from_env(env, attr)
|
||||
config_obj = Config.parse_obj(config_dict)
|
||||
self.__dict__.update(config_obj.__dict__)
|
||||
logger.info(f"Config loaded from env")
|
||||
logger.info("Config loaded from env")
|
||||
|
||||
@staticmethod
|
||||
def __val_from_env(env: str, attr: tuple):
|
||||
|
||||
@@ -206,7 +206,7 @@ class BangumiDatabase(DataConnector):
|
||||
def not_complete(self) -> list[BangumiData]:
|
||||
# Find eps_complete = False
|
||||
condition = "eps_complete = 0"
|
||||
data = self._search_datas(
|
||||
self._search_datas(
|
||||
table_name=self.__table_name,
|
||||
condition=condition,
|
||||
)
|
||||
|
||||
@@ -124,7 +124,7 @@ class DataConnector:
|
||||
|
||||
def _table_exists(self, table_name: str) -> bool:
|
||||
self._cursor.execute(
|
||||
f"SELECT name FROM sqlite_master WHERE type='table' AND name=?;",
|
||||
"SELECT name FROM sqlite_master WHERE type='table' AND name=?;",
|
||||
(table_name,),
|
||||
)
|
||||
return len(self._cursor.fetchall()) == 1
|
||||
|
||||
@@ -4,7 +4,6 @@ import time
|
||||
from aria2p import API, Client, ClientException
|
||||
|
||||
from module.conf import settings
|
||||
from module.downloader.exceptions import ConflictError
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ class QbDownloader:
|
||||
time.sleep(5)
|
||||
times += 1
|
||||
except Forbidden403Error:
|
||||
logger.error(f"Login refused by qBittorrent Server")
|
||||
logger.info(f"Please release the IP in qBittorrent Server")
|
||||
logger.error("Login refused by qBittorrent Server")
|
||||
logger.info("Please release the IP in qBittorrent Server")
|
||||
break
|
||||
except APIConnectionError:
|
||||
logger.error(f"Cannot connect to qBittorrent Server")
|
||||
logger.info(f"Please check the IP and port in WebUI settings")
|
||||
logger.error("Cannot connect to qBittorrent Server")
|
||||
logger.info("Please check the IP and port in WebUI settings")
|
||||
time.sleep(10)
|
||||
times += 1
|
||||
except Exception as e:
|
||||
|
||||
@@ -62,7 +62,7 @@ class DownloadClient(TorrentPath):
|
||||
self.client.prefs_init(prefs=prefs)
|
||||
try:
|
||||
self.client.add_category("BangumiCollection")
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
logger.debug("[Downloader] Cannot add new category, maybe already exists.")
|
||||
if settings.downloader.path == "":
|
||||
prefs = self.client.get_app_prefs()
|
||||
@@ -109,7 +109,7 @@ class DownloadClient(TorrentPath):
|
||||
|
||||
def delete_torrent(self, hashes):
|
||||
self.client.torrents_delete(hashes)
|
||||
logger.info(f"[Downloader] Remove torrents.")
|
||||
logger.info("[Downloader] Remove torrents.")
|
||||
|
||||
def add_torrent(self, torrent: dict):
|
||||
if self.client.torrents_add(
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import logging
|
||||
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from module.database import BangumiDatabase
|
||||
from module.downloader import DownloadClient
|
||||
from module.models import BangumiData
|
||||
|
||||
@@ -64,7 +64,7 @@ class RequestURL:
|
||||
req = requests.head(url=url, headers=self.header, timeout=5)
|
||||
req.raise_for_status()
|
||||
return True
|
||||
except requests.RequestException as e:
|
||||
except requests.RequestException:
|
||||
logger.debug(f"[Network] Cannot connect to {url}.")
|
||||
return False
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ from module.conf import settings
|
||||
from module.database import BangumiDatabase
|
||||
from module.models import Notification
|
||||
|
||||
from .plugin import *
|
||||
from .plugin import (
|
||||
BarkNotification,
|
||||
ServerChanNotification,
|
||||
TelegramNotification,
|
||||
WecomNotification,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -26,8 +31,7 @@ class PostNotification:
|
||||
def __init__(self):
|
||||
Notifier = getClient(settings.notification.type)
|
||||
self.notifier = Notifier(
|
||||
token=settings.notification.token,
|
||||
chat_id=settings.notification.chat_id
|
||||
token=settings.notification.token, chat_id=settings.notification.chat_id
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -37,11 +41,11 @@ class PostNotification:
|
||||
if poster_path:
|
||||
poster_link = "https://mikanani.me" + poster_path
|
||||
text = f"""
|
||||
番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n{poster_link}\n
|
||||
番剧名称:{notify.official_title}\n季度:第{notify.season}季\n更新集数:第{notify.episode}集\n{poster_link}\n
|
||||
"""
|
||||
else:
|
||||
text = f"""
|
||||
番剧名称:{notify.official_title}\n季度: 第{notify.season}季\n更新集数: 第{notify.episode}集\n
|
||||
番剧名称:{notify.official_title}\n季度:第{notify.season}季\n更新集数:第{notify.episode}集\n
|
||||
"""
|
||||
return text
|
||||
|
||||
@@ -61,6 +65,7 @@ class PostNotification:
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.notifier.__exit__(exc_type, exc_val, exc_tb)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
info = Notification(
|
||||
official_title="魔法纪录 魔法少女小圆外传",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
|
||||
from module.conf import settings
|
||||
from module.database import RSSDatabase
|
||||
from module.models import BangumiData, RSSTorrents
|
||||
from module.network import RequestContent, TorrentInfo
|
||||
@@ -25,4 +24,4 @@ class RSSPoller(RSSDatabase):
|
||||
rss_datas: list[RSSTorrents] = self.get_rss_data()
|
||||
with RequestContent() as req:
|
||||
for rss_data in rss_datas:
|
||||
torrents = self.polling(rss_data.url, req)
|
||||
self.polling(rss_data.url, req)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import logging
|
||||
|
||||
from .json_config import load, save
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
Reference in New Issue
Block a user