Skip to content

Commit 51b6580

Browse files
committed
chore: 添加代码审查工具和工作流
- 创建了 .github/workflows/code-quality.yml 工作流配置 - 在 pyproject.toml 中添加了开发依赖(black、flake8、isort、mypy、bandit、pre-commit) - 创建了 .pre-commit-config.yaml 配置文件 - 配置了提交前的代码审查钩子 这些更改将确保每次提交和PR都会自动进行代码质量检查,提高代码的可读性和可维护性。
1 parent 3ab0a49 commit 51b6580

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/code-quality.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Code Quality
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
code-quality:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: '3.10'
14+
- name: Install dependencies
15+
run: |
16+
python -m pip install --upgrade pip
17+
pip install -e .[dev]
18+
- name: Run Black
19+
run: black --check .
20+
- name: Run isort
21+
run: isort --check-only .
22+
- name: Run Flake8
23+
run: flake8 .
24+
- name: Run mypy
25+
run: mypy src/
26+
- name: Run Bandit
27+
run: bandit -r src/

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.11.0
4+
hooks:
5+
- id: black
6+
- repo: https://github.com/pycqa/isort
7+
rev: 5.12.0
8+
hooks:
9+
- id: isort
10+
- repo: https://github.com/pycqa/flake8
11+
rev: 6.1.0
12+
hooks:
13+
- id: flake8
14+
- repo: https://github.com/pre-commit/mirrors-mypy
15+
rev: v1.7.1
16+
hooks:
17+
- id: mypy

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ dependencies = [
1717
"pytest"
1818
]
1919

20+
[project.optional-dependencies]
21+
dev = [
22+
"black",
23+
"flake8",
24+
"isort",
25+
"mypy",
26+
"bandit",
27+
"pre-commit"
28+
]
29+
2030
[project.entry-points.pytest11]
2131
dynamic-params = "dynamic_params.plugin"
2232

0 commit comments

Comments
 (0)