-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruff.toml
185 lines (166 loc) · 4.63 KB
/
ruff.toml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
line-length = 120
target-version = "py38"
select = [
"C", # mccabe
# "D", # pydocstyle
"E", # pycodestyle errors
"W", # pycodestyle warnings
"I", # isort
"F", # Pyflakes
# "N", # pep8-naming
# "UP", # pyupgrade
"S", # bandit
"YTT",
"ANN",
"ASYNC",
"BLE",
"FBT",
"B",
"A",
"COM",
"CPY",
"C4",
"DTZ",
"T10",
"EM",
"EXE",
"ISC",
"ICN",
"G",
"INP",
"PIE",
"T20",
"PYI",
"PT",
"Q",
"RSE",
"RET",
"SLF",
"SLOT",
"SIM",
"TID",
"TCH",
"INT",
"ARG",
"PTH",
"TD",
"FIX",
"ERA",
# "PD", # pandas-vet: has checks on pandas.DataFrame that trigger on spark.DataFrame and don't make sense on spark
"PGH",
"PL",
"TRY",
"FLY",
"NPY",
"AIR",
"PERF",
"RUF",
]
ignore = [
"ARG005", # Unused lambda argument
# If a method expect as argument a higher order function of type "A -> B", I find it more confusing to feed it
# with "lambda: B.default_value" than with "lambda a: B.default_value", even if a is not used.
"RET504", # Unnecessary assignment to `...` before `return` statement
# Naming the return argument before returning it is makes the code more readable and easier to debug.
"RET505", # Unnecessary `else` after `return` statement
"RET506", # Unnecessary `else` after `raise` statement
# I find the functionnal-programming version less confusing than the imperative version:
#
# # Functionnal-programming version:
# if P:
# return B
# else:
# return C
#
# # Imperative version:
# if P:
# return B
# return C
#
"SIM108", # Replace multiline if then else with one-liners
# # Personally, I find this:
# if predicate():
# x = 1
# else:
# x = 2
#
# # More readable than this:
# x = 1 if predicate() else 2
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function definition
# These rules makes sense but there are several cases where working around it makes the code more confusing than less
# Plus, the spark API does not follow this rule already (for instance, df.show(10, true) works)
"ANN101", # Missing type annotation for `self` in method
# This rule is not necessary when self is automatically infered by smart type checkers.
"TD002", # Missing author in TO-DO;
# This is a small project, with currently only one author.
"SIM114", # Combine `if` branches using logical `or` operator
# # Personally, I find this:
# if my_object.attribute_a == my_object.attribute_b:
# return None
# elif my_object.attribute_c == my_object.attribute_d:
# return None
#
# # More readable than this:
# if my_object.attribute_a != my_object.attribute_b or my_object.attribute_c == my_object.attribute_d:
# return None
# TODO: These warnings might be fixable but it will take some effort
"T201", # `print` found
"FIX002", # Line contains TO-DO
"TD003", # Missing issue link on the line following this TO-DO
"C901", # method is too complex
"PLR2004", # Magic value used in comparison
#"PGH003"
]
fixable = [
"A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W",
"ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE",
"FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL",
"PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH",
"TID", "TRY", "UP", "YTT"
]
unfixable = []
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
extend-exclude = [
"sandbox/",
"conftest.py",
]
[mccabe]
max-complexity = 10
[lint.isort]
known-first-party = ["spark_frame"]
[pylint]
max-args = 8 # PLR0913: Too many arguments in function definition (8 > 5)
[per-file-ignores]
"tests/**/*.py" = [
# at least this three should be fine in tests:
"S101", # asserts allowed in tests...
"PLR2004", # Magic value used in comparison
"ANN201", # Missing return type annotation for public function
# "ARG", # Unused function args -> fixtures nevertheless are functionally relevant...
# "FBT", # Don't care about booleans as positional arguments in tests, e.g. via @pytest.mark.parametrize()
# # The below are debateable
# "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]