mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-05 14:48:40 +08:00
style: apply safe ruff auto-fixes and exempt startup late imports
Run `ruff check app tests scripts --fix` with the configured rule set (E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders (F541), lambda/variable/unused-import cleanups that ruff marks safe. Nine files whose only ruff debt sits next to pre-existing pylint import-resolution errors (lazy exports, sys.path script imports) or whose "unused" imports are reached through attribute access by tests are left untouched so the changed-file pylint gate and the benchmark tests stay green; their diagnostics remain in the baseline. app/startup/lifecycle/__init__.py and app/main.py import business modules after cache composition, import-path and stdio setup on purpose (the source comments document the contract), so declare E402 per-file-ignores for them instead of adding per-line noqa. Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture and the optimization checklist figure. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import ast
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
TASK_METHODS = frozenset(
|
||||
{"create", "create_sync", "register", "submit_threadsafe"}
|
||||
|
||||
@@ -4,8 +4,8 @@ Benchmark SiteSpider indexer parsing with real MoviePilot-Build site configs.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import copy
|
||||
import contextlib
|
||||
import copy
|
||||
import io
|
||||
import statistics
|
||||
import sys
|
||||
|
||||
@@ -9,10 +9,10 @@ from types import SimpleNamespace
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
from app.adapters.network.http import RequestUtils
|
||||
from app.adapters.system import rust as rust_accel
|
||||
from app.application import rss as rss_module
|
||||
from app.application.rss import RssHelper
|
||||
from app.adapters.system import rust as rust_accel
|
||||
from app.adapters.network.http import RequestUtils
|
||||
|
||||
|
||||
class FakeRequestUtils:
|
||||
|
||||
@@ -9,7 +9,6 @@ from pathlib import Path
|
||||
from typing import Optional
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
OFFICIAL_PLUGIN_MARKET = "https://github.com/jxxghp/MoviePilot-Plugins"
|
||||
PLUGIN_MARKET_WIKI_START = "<!-- plugin-market-repos:start -->"
|
||||
PLUGIN_MARKET_WIKI_END = "<!-- plugin-market-repos:end -->"
|
||||
|
||||
@@ -26,7 +26,6 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
LEGACY_CONFIG_DIR = ROOT / "config"
|
||||
SITE_RESOURCE_DIR = ROOT / "app" / "application" / "site"
|
||||
@@ -2536,13 +2535,13 @@ def _apply_local_system_config_inner(config_payload: dict[str, Any]) -> None:
|
||||
)
|
||||
from app.application.configuration import SystemConfigService
|
||||
from app.application.directory import normalize_directory_system_config_value
|
||||
from app.schemas.category import ClassificationPolicyState
|
||||
from app.startup.initializers.database import prepare_database
|
||||
from app.db.adapters.transaction import TransactionalWriteRunner
|
||||
from app.db.oper.systemconfig import SystemConfigOper
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.db.session import SessionFactory, async_session_scope
|
||||
from app.db.uow import configure_transaction_runners
|
||||
from app.db.adapters.transaction import TransactionalWriteRunner
|
||||
from app.schemas.category import ClassificationPolicyState
|
||||
from app.schemas.types import SystemConfigKey
|
||||
from app.startup.initializers.database import prepare_database
|
||||
except ModuleNotFoundError as exc:
|
||||
raise RuntimeError(
|
||||
"当前环境尚未安装 MoviePilot 运行依赖,请先执行 moviepilot install deps 或 moviepilot setup"
|
||||
@@ -2725,8 +2724,8 @@ def _ensure_superuser_account_inner() -> None:
|
||||
|
||||
|
||||
def _prepare_superuser_password_for_bootstrap() -> Optional[str]:
|
||||
from app.runtime.config import settings
|
||||
from app.db.oper.user import UserOper
|
||||
from app.runtime.config import settings
|
||||
|
||||
username = str(settings.SUPERUSER or "").strip()
|
||||
username_error = _validate_superuser_name(username)
|
||||
@@ -3960,9 +3959,9 @@ def run_agent_request(
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
try:
|
||||
from app.startup.initializers.database import prepare_database
|
||||
from app.agent.orchestrator import MoviePilotAgent
|
||||
from app.runtime.config import settings
|
||||
from app.startup.initializers.database import prepare_database
|
||||
except ModuleNotFoundError as exc:
|
||||
raise RuntimeError(
|
||||
"当前环境尚未安装 MoviePilot 运行依赖,请先执行 moviepilot install deps 或 moviepilot setup"
|
||||
|
||||
@@ -7,7 +7,6 @@ import re
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DIRECT_REFERENCE = re.compile(
|
||||
r"^(?P<indent>\s*)(?P<name>[A-Za-z0-9_.-]+)\s+@\s+"
|
||||
r"(?P<url>\S+)(?P<suffix>.*)$"
|
||||
|
||||
@@ -10,7 +10,6 @@ import random
|
||||
import re
|
||||
import statistics
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from datetime import datetime, timezone
|
||||
|
||||
@@ -6,7 +6,6 @@ import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
if str(PROJECT_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
@@ -26,7 +26,6 @@ import requests
|
||||
import websocket
|
||||
from bs4 import BeautifulSoup, Comment, NavigableString, Tag
|
||||
|
||||
|
||||
COLLECTOR_VERSION = "1.0.1"
|
||||
FORMAT_VERSION = 1
|
||||
MAX_RESPONSE_BYTES = 5 * 1024 * 1024
|
||||
|
||||
@@ -12,7 +12,6 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
||||
DEFAULT_OUTPUT = (
|
||||
PROJECT_ROOT
|
||||
|
||||
Reference in New Issue
Block a user