Skip to content

Commit 7412fe9

Browse files
committed
update: add ruff lint
1 parent 1608a77 commit 7412fe9

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

root/.config/ruff/pyproject.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

root/.config/ruff/ruff.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 最大行宽,超过则触发 E501
2+
# 119 = GitHub/GitLab 代码审查页面不折行的最大宽度,也是 Django 社区常用值
3+
# 对比: PEP 8 标准 79, Black 默认 88
4+
line-length = 119
5+
6+
[lint]
7+
# 启用的规则集,与 VS Code ruff 扩展配置保持一致
8+
# C - mccabe 复杂度检查(如 C901: 函数圈复杂度超过阈值)
9+
# E - pycodestyle 错误(如 E501: 行过长, E401: 多个 import 写在一行)
10+
# F - pyflakes 检查(如 F401: 未使用的 import, F841: 未使用的变量)
11+
# I - isort import 排序(如 I001: import 顺序不正确, I002: 缺少 __future__ import)
12+
# W - pycodestyle 警告(如 W291: 行尾多余空格, W605: 无效转义序列)
13+
select = ["C", "E", "F", "I", "W"]

root/.vscode-server/data/Machine/settings.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,27 @@
88
"[python]": {
99
"editor.formatOnSave": true,
1010
"editor.codeActionsOnSave": {
11-
"source.fixAll": "explicit",
12-
"source.organizeImports": "explicit"
11+
"source.organizeImports.ruff": "explicit"
1312
},
1413
"editor.defaultFormatter": "charliermarsh.ruff"
1514
},
1615
"python.venvPath": "~/.venv",
1716
"python.terminal.activateEnvironment": false,
18-
"notebook.formatOnSave.enabled": true,
19-
"notebook.codeActionsOnSave": {
20-
"notebook.source.fixAll": "explicit",
21-
"notebook.source.organizeImports": "explicit"
22-
},
17+
"ruff.lint.enable": true,
2318
"ruff.nativeServer": "on",
2419
"ruff.lineLength": 119,
2520
"ruff.lint.select": [
2621
"C",
2722
"E",
2823
"F",
24+
"I",
2925
"W"
3026
],
27+
"notebook.formatOnSave.enabled": true,
28+
"notebook.codeActionsOnSave": {
29+
"notebook.source.fixAll": "explicit",
30+
"notebook.source.organizeImports": "explicit"
31+
},
3132
"clang-format.style": "{IndentWidth: 4, BasedOnStyle: google, AlignConsecutiveAssignments: true, ColumnLimit: 0}",
3233
"git.ignoredRepositories": [
3334
"/opt"

0 commit comments

Comments
 (0)