mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 00:46:57 +08:00
更新 .gitignore 文件以包含 Pylint 相关文件,并修改 system.py 中的成功返回逻辑
This commit is contained in:
@@ -0,0 +1,96 @@
|
|||||||
|
name: Pylint Code Quality Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
# 在推送到任何分支时运行
|
||||||
|
push:
|
||||||
|
branches: [ "main", "v2", "develop" ]
|
||||||
|
paths:
|
||||||
|
- '**.py'
|
||||||
|
# 在PR时运行
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main", "v2", "develop" ]
|
||||||
|
paths:
|
||||||
|
- '**.py'
|
||||||
|
# 允许手动触发
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pylint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Pylint Code Quality Check
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.11'
|
||||||
|
|
||||||
|
- name: Cache pip dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements.in') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pylint
|
||||||
|
# 安装项目依赖
|
||||||
|
if [ -f requirements.txt ]; then
|
||||||
|
pip install -r requirements.txt
|
||||||
|
elif [ -f requirements.in ]; then
|
||||||
|
pip install -r requirements.in
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Verify pylint config
|
||||||
|
run: |
|
||||||
|
# 检查项目中的pylint配置文件是否存在
|
||||||
|
if [ -f .pylintrc ]; then
|
||||||
|
echo "✅ 找到项目配置文件: .pylintrc"
|
||||||
|
echo "配置文件内容预览:"
|
||||||
|
head -10 .pylintrc
|
||||||
|
else
|
||||||
|
echo "❌ 未找到 .pylintrc 配置文件"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- name: Run pylint
|
||||||
|
run: |
|
||||||
|
# 运行pylint,检查主要的Python文件
|
||||||
|
echo "🚀 运行 Pylint 错误检查..."
|
||||||
|
|
||||||
|
# 检查主要目录 - 只关注错误,如果有错误则退出
|
||||||
|
echo "📂 检查 app/ 目录..."
|
||||||
|
pylint app/ --output-format=colorized --reports=yes --score=yes
|
||||||
|
|
||||||
|
# 检查根目录的Python文件
|
||||||
|
echo "📂 检查根目录 Python 文件..."
|
||||||
|
for file in $(find . -name "*.py" -not -path "./.*" -not -path "./.venv/*" -not -path "./build/*" -not -path "./dist/*" -not -path "./tests/*" -not -path "./docs/*" -not -path "./__pycache__/*" -maxdepth 1); do
|
||||||
|
echo "检查文件: $file"
|
||||||
|
pylint "$file" --output-format=colorized || exit 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# 生成详细报告
|
||||||
|
echo "📊 生成 Pylint 详细报告..."
|
||||||
|
pylint app/ --output-format=json > pylint-report.json || true
|
||||||
|
|
||||||
|
# 显示评分(仅供参考)
|
||||||
|
echo "📈 Pylint 评分(仅供参考):"
|
||||||
|
pylint app/ --score=yes --reports=no | tail -2 || true
|
||||||
|
|
||||||
|
- name: Upload pylint report
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: pylint-report
|
||||||
|
path: pylint-report.json
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: |
|
||||||
|
echo "🎉 Pylint 检查完成!"
|
||||||
|
echo "✅ 没有发现语法错误或严重问题"
|
||||||
|
echo "📊 详细报告已保存为构建工件"
|
||||||
+5
-1
@@ -23,4 +23,8 @@ config/cache/
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.log
|
*.log
|
||||||
.vscode
|
.vscode
|
||||||
venv
|
venv
|
||||||
|
|
||||||
|
# Pylint
|
||||||
|
pylint-report.json
|
||||||
|
.pylint.d/
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
[MASTER]
|
||||||
|
# 指定Python路径
|
||||||
|
init-hook='import sys; sys.path.append(".")'
|
||||||
|
|
||||||
|
# 忽略的文件和目录
|
||||||
|
ignore=.git,__pycache__,.venv,build,dist,tests,docs
|
||||||
|
|
||||||
|
# 并行作业数量
|
||||||
|
jobs=0
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
# 只关注错误级别的问题,禁用警告、约定和重构建议
|
||||||
|
# E = Error (错误) - 会导致构建失败
|
||||||
|
# W = Warning (警告) - 仅显示,不会失败
|
||||||
|
# R = Refactor (重构建议) - 仅显示,不会失败
|
||||||
|
# C = Convention (约定) - 仅显示,不会失败
|
||||||
|
# I = Information (信息) - 仅显示,不会失败
|
||||||
|
|
||||||
|
# 禁用大部分警告、约定和重构建议,只保留错误和重要警告
|
||||||
|
disable=all
|
||||||
|
enable=error,
|
||||||
|
syntax-error,
|
||||||
|
undefined-variable,
|
||||||
|
used-before-assignment,
|
||||||
|
unreachable,
|
||||||
|
return-outside-function,
|
||||||
|
yield-outside-function,
|
||||||
|
continue-in-finally,
|
||||||
|
nonlocal-without-binding,
|
||||||
|
undefined-loop-variable,
|
||||||
|
redefined-builtin,
|
||||||
|
not-callable,
|
||||||
|
assignment-from-no-return,
|
||||||
|
no-value-for-parameter,
|
||||||
|
too-many-function-args,
|
||||||
|
unexpected-keyword-arg,
|
||||||
|
redundant-keyword-arg,
|
||||||
|
import-error,
|
||||||
|
relative-beyond-top-level
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
# 设置报告格式
|
||||||
|
output-format=colorized
|
||||||
|
reports=yes
|
||||||
|
score=yes
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
# 最大行长度
|
||||||
|
max-line-length=120
|
||||||
|
# 缩进大小
|
||||||
|
indent-string=' '
|
||||||
|
|
||||||
|
[DESIGN]
|
||||||
|
# 最大参数数量
|
||||||
|
max-args=10
|
||||||
|
# 最大本地变量数量
|
||||||
|
max-locals=20
|
||||||
|
# 最大分支数量
|
||||||
|
max-branches=15
|
||||||
|
# 最大语句数量
|
||||||
|
max-statements=50
|
||||||
|
# 最大父类数量
|
||||||
|
max-parents=7
|
||||||
|
# 最大属性数量
|
||||||
|
max-attributes=10
|
||||||
|
# 最小公共方法数量
|
||||||
|
min-public-methods=1
|
||||||
|
# 最大公共方法数量
|
||||||
|
max-public-methods=25
|
||||||
|
|
||||||
|
[SIMILARITIES]
|
||||||
|
# 最小相似行数
|
||||||
|
min-similarity-lines=6
|
||||||
|
# 忽略注释
|
||||||
|
ignore-comments=yes
|
||||||
|
# 忽略文档字符串
|
||||||
|
ignore-docstrings=yes
|
||||||
|
# 忽略导入
|
||||||
|
ignore-imports=yes
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
# 生成缺失成员提示的类列表
|
||||||
|
generated-members=requests.packages.urllib3
|
||||||
@@ -301,7 +301,9 @@ def set_setting(key: str, value: Union[list, dict, bool, int, str] = None,
|
|||||||
value=value,
|
value=value,
|
||||||
change_type="update"
|
change_type="update"
|
||||||
))
|
))
|
||||||
return schemas.Response(success=True if success else False, message=message)
|
elif success is None:
|
||||||
|
success = True
|
||||||
|
return schemas.Response(success=success, message=message)
|
||||||
elif key in {item.value for item in SystemConfigKey}:
|
elif key in {item.value for item in SystemConfigKey}:
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
value = list(filter(None, value))
|
value = list(filter(None, value))
|
||||||
|
|||||||
Reference in New Issue
Block a user