-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathridiom.toml
More file actions
104 lines (85 loc) · 2.98 KB
/
ridiom.toml
File metadata and controls
104 lines (85 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ===============================================
# RIdiom (RefactoringIdioms) 工具的配置
# (支持正向 "refactor" 和反向 "explain")
# ===============================================
[ridiom]
# 1. 全局配置 (Global Configuration)
# 这些设置对所有模式都有效
# 要检查的路径。["."] 代表从当前目录开始扫描。
include = ["."]
# 要排除的文件和目录。
exclude = [
".git",
".venv",
"venv",
".ruff_cache",
".pytest_cache",
".mypy_cache",
"build",
"dist",
"__pypackages__",
]
# 允许使用 # noqa: RID001 这样的内联注释来禁用检查。
enable-noqa = true
# ===============================================
# 2. 核心转换配置 (Core Transformation)
# ===============================================
# "mode" 用于选择工具的行为
#
# "refactor" = (RIdiom 模式)
# 正向转换:检测“非地道”代码,并将其重构为“地道”代码。
#
# "explain" = (Deldiom 模式)
# 反向转换:检测“地道”代码,并将其转换为“非地道”代码以供解释。
mode = "refactor" # 默认保持为 RIdiom 模式
# ===============================================
# 3. 规则配置 (Rules Configuration)
# ===============================================
[ridiom.rules]
# 规则选择列表。
select = [
"list-comprehension",
"set-comprehension",
"dict-comprehension",
"chain-comparison",
"truth-value-test",
"for-else",
"assign-multiple-targets",
"star-in-func-call",
"for-multiple-targets",
]
# 在 "全选" 模式 (即 select = []) 下,明确禁用某些规则。
ignore = []
# --- 细粒度规则配置 ---
# 以下设置为每条规则提供了更精细的控制
[ridiom.rules.list-comprehension]
# 是否转换带 if 条件的列表推导式。
refactor-with-if = true
[ridiom.rules.set-comprehension]
# 是否转换带 if 条件的集合推导式。
refactor-with-if = true
[ridiom.rules.dict-comprehension]
# 是否转换带 if 条件的字典推导式。
refactor-with-if = true
[ridiom.rules.chain-comparison]
# 重构限制的最多*操作数*数量。
# 设为 false 意味着此规则默认*禁用*,
max-operands-to-refactor = false
[ridiom.rules.assign-multiple-targets]
# 重构限制的最多*赋值*数量。
# 设为 false 意味着此规则默认*禁用*。
max-assignments-to-refactor = false
[ridiom.rules.star-in-func-call]
#重构限制的最多*连续解包元素*数量。
# 设为 false 意味着此规则默认*禁用*。
max-elements-to-unpack = false
[ridiom.rules.for-multiple-targets]
#重构限制的最多*循环体内解包元素*数量。
# 设为 false 意味着此规则默认*禁用*。
max-elements-to-unpack = false
# ===============================================
# 4. 输出配置 (Output Configuration)
# ===============================================
[ridiom.output]
# 指定输出文件的路径
file = "report.json"