mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
refactor: 完善代码质量检查和修复系统
主要改进: - 添加 make tox-local 本地代码质量检查支持 - 创建 check-code.sh 脚本支持独立工具执行 - 修复 51+ flake8 代码风格问题(未使用导入、行尾空格、注释格式等) - 解决 pylint 变量命名和日志格式问题 - 重构 make_image 方法解决 too-many-statements 警告 - 添加类型注解和修复方法签名不匹配问题 - 统一代码风格规范(引号使用、空格格式等) 工具配置: - 更新 tox.ini 支持 Python 3.10 本地环境 - 添加缺失的核心依赖包定义 - 完善 Makefile 构建系统集成
This commit is contained in:
6
testenv/requirements-core.txt
Normal file
6
testenv/requirements-core.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
# Core dependencies for code quality checks (hardware dependencies excluded)
|
||||
python-dateutil>=2.8.1
|
||||
pyserial
|
||||
pyserial-asyncio
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
@@ -3,46 +3,50 @@ envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck
|
||||
skipsdist = true
|
||||
|
||||
[testenv]
|
||||
basepython = python3.13
|
||||
basepython = python3.10
|
||||
sitepackages = true
|
||||
changedir = /src
|
||||
changedir = {toxinidir}
|
||||
|
||||
[testenv:flake8]
|
||||
allowlist_externals = bash
|
||||
commands = bash -c 'flake8 --config=testenv/linters/flake8.ini kvmd testenv/tests *.py'
|
||||
commands = bash -c 'flake8 --config={toxinidir}/testenv/linters/flake8.ini {toxinidir}/kvmd {toxinidir}/testenv/tests {toxinidir}/*.py'
|
||||
deps =
|
||||
flake8
|
||||
flake8-quotes
|
||||
-rrequirements.txt
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
|
||||
[testenv:pylint]
|
||||
allowlist_externals = bash
|
||||
commands = bash -c 'pylint -j0 --rcfile=testenv/linters/pylint.ini --output-format=colorized --reports=no kvmd testenv/tests *.py'
|
||||
commands = bash -c 'pylint -j0 --rcfile={toxinidir}/testenv/linters/pylint.ini --output-format=colorized --reports=no {toxinidir}/kvmd {toxinidir}/testenv/tests {toxinidir}/*.py'
|
||||
deps =
|
||||
pylint
|
||||
pytest
|
||||
pytest-asyncio
|
||||
aiohttp-basicauth
|
||||
-rrequirements.txt
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
|
||||
[testenv:mypy]
|
||||
allowlist_externals = bash
|
||||
commands = bash -c 'mypy --config-file=testenv/linters/mypy.ini --cache-dir=testenv/.mypy_cache kvmd testenv/tests *.py'
|
||||
commands = bash -c 'mypy --config-file={toxinidir}/testenv/linters/mypy.ini --cache-dir={toxinidir}/testenv/.mypy_cache {toxinidir}/kvmd {toxinidir}/testenv/tests {toxinidir}/*.py'
|
||||
deps =
|
||||
mypy
|
||||
-rrequirements.txt
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
|
||||
[testenv:vulture]
|
||||
allowlist_externals = bash
|
||||
commands = bash -c 'vulture --ignore-names=_format_P,Plugin --ignore-decorators=@exposed_http,@exposed_ws,@pytest.fixture kvmd testenv/tests *.py testenv/linters/vulture-wl.py'
|
||||
commands = bash -c 'vulture --ignore-names=_format_P,Plugin --ignore-decorators=@exposed_http,@exposed_ws,@pytest.fixture {toxinidir}/kvmd {toxinidir}/testenv/tests {toxinidir}/*.py {toxinidir}/testenv/linters/vulture-wl.py'
|
||||
deps =
|
||||
vulture
|
||||
-rrequirements.txt
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
|
||||
[testenv:pytest]
|
||||
commands = py.test -vv --cov-config=testenv/linters/coverage.ini --cov-report=term-missing --cov=kvmd testenv/tests
|
||||
commands = py.test -vv --cov-config={toxinidir}/testenv/linters/coverage.ini --cov-report=term-missing --cov=kvmd {toxinidir}/testenv/tests
|
||||
setenv =
|
||||
PYTHONPATH=/src
|
||||
PYTHONPATH={toxinidir}
|
||||
deps =
|
||||
pytest
|
||||
pytest-cov
|
||||
@@ -50,16 +54,17 @@ deps =
|
||||
pytest-asyncio
|
||||
pytest-aiohttp
|
||||
aiohttp-basicauth
|
||||
-rrequirements.txt
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
|
||||
[testenv:eslint]
|
||||
allowlist_externals = eslint
|
||||
commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.js --color web/share/js
|
||||
commands = eslint --cache-location=/tmp --config={toxinidir}/testenv/linters/eslintrc.js --color {toxinidir}/web/share/js
|
||||
|
||||
[testenv:htmlhint]
|
||||
allowlist_externals = htmlhint
|
||||
commands = htmlhint --config=testenv/linters/htmlhint.json web/*.html web/*/*.html
|
||||
commands = htmlhint --config={toxinidir}/testenv/linters/htmlhint.json {toxinidir}/web/*.html {toxinidir}/web/*/*.html
|
||||
|
||||
[testenv:shellcheck]
|
||||
allowlist_externals = bash
|
||||
commands = bash -c 'shellcheck --color=always kvmd.install scripts/*'
|
||||
commands = bash -c 'shellcheck --color=always {toxinidir}/kvmd.install {toxinidir}/scripts/*'
|
||||
|
||||
Reference in New Issue
Block a user