forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ruff.toml
325 lines (293 loc) · 10.8 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
extend = "pyproject.toml"
lint.ignore = [
# NOTE: to find a good code to fix, run:
# ruff --select="ALL" --statistics astropy/<subpackage>
# flake8-annotations (ANN) : static typing
"ANN001", # Function argument without type annotation
"ANN003", # `**kwargs` without type annotation
"ANN201", # Public function without return type annotation
"ANN202", # Private function without return type annotation
"ANN401", # Use of `Any` type
# flake8-unused-arguments (ARG)
"ARG001", # unused-function-argument
"ARG002", # unused-method-argument
"ARG003", # unused-class-method-argument
"ARG004", # unused-static-method-argument
"ARG005", # unused-lambda-argument
# flake8-bugbear (B)
"B006", # MutableArgumentDefault
"B007", # UnusedLoopControlVariable
"B023", # FunctionUsesLoopVariable
"B028", # No-explicit-stacklevel
"B904", # RaiseWithoutFromInsideExcept
"B905", # ZipWithoutExplicitStrict # requires 3.10+
# flake8-blind-except (BLE)
"BLE001", # blind-except
# mccabe (C90) : code complexity
# TODO: configure maximum allowed complexity.
"C901", # McCabeComplexity
# pydocstyle (D)
# Missing Docstrings
"D100", # undocumented-public-module
"D101", # undocumented-public-class
"D103", # undocumented-public-function
"D104", # undocumented-public-package
"D205", # blank-line-after-summary
# Quotes Issues
"D300", # triple-single-quotes
"D301", # escape-sequence-in-docstring
# Docstring Content Issues
"D403", # first-line-capitalized
"D404", # docstring-starts-with-this
"D401", # non-imperative-mood.
"D414", # empty-docstring-section
"D419", # docstring is empty
# flake8-datetimez (DTZ)
"DTZ001", # call-datetime-without-tzinfo
"DTZ005", # call-datetime-now-without-tzinfo
# pycodestyle (E, W)
"E501", # line-too-long
"E721", # type-comparison
"E731", # lambda-assignment
# flake8-errmsg (EM) : nicer error tracebacks
"EM101", # raw-string-in-exception
"EM102", # f-string-in-exception
"EM103", # dot-format-in-exception
# eradicate (ERA)
# NOTE: be careful that developer notes are kept.
"ERA001", # commented-out-code
# flake8-executable (EXE)
"EXE002", # shebang-missing-executable-file
# Pyflakes (F)
"F841", # unused-variable
# flake8-boolean-trap (FBT) : boolean flags should be kwargs, not args
# NOTE: a good thing to fix, but changes API.
"FBT001", # boolean-positional-arg-in-function-definition
"FBT002", # boolean-default-value-in-function-definition
"FBT003", # boolean-positional-value-in-function-call
# flake8-fixme (FIX)
"FIX001", # Line contains FIXME. this should be fixed or at least FIXME replaced with TODO
"FIX004", # Line contains HACK. replace HACK with NOTE.
# flake8-import-conventions (ICN) : use conventional import aliases
"ICN001", # import-conventions
# pep8-naming (N)
# NOTE: some of these can/should be fixed, but this changes the API.
"N801", # invalid-class-name
"N802", # invalid-function-name
"N803", # invalid-argument-name
"N804", # invalid-first-argument-name-for-class-method
"N805", # invalid-first-argument-name-for-method
"N807", # dunder-function-name
"N813", # camelcase-imported-as-lowercase
"N815", # mixed-case-variable-in-class-scope
"N816", # mixed-case-variable-in-global-scope
"N818", # error-suffix-on-exception-name
# NumPy-specific rules (NPY)
"NPY002", # Replace legacy `np.random.rand` call with `np.random.Generator` (2023-05-03)
# Perflint (PERF)
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PERF401", # Use a list comprehension to create a transformed list
# pygrep-hooks (PGH)
"PGH001", # eval
# Pylint (PLC, PLE, PLR, PLW)
"PLE0101", # return-in-init
"PLR0124", # Name compared with itself
"PLR0402", # ConsiderUsingFromImport
"PLR0911", # too-many-return-statements
"PLR0912", # too-many-branches
"PLR0913", # too-many-args
"PLR0915", # too-many-statements
"PLR1714", # Consider merging multiple comparisons
"PLR2004", # MagicValueComparison
"PLR5501", # collapsible-else-if
"PLW0603", # global-statement
"PLW2901", # redefined-loop-name
# flake8-pytest-style (PT)
"PT001", # pytest-fixture-incorrect-parentheses-style
"PT003", # pytest-extraneous-scope-function
"PT004", # pytest-missing-fixture-name-underscore
"PT006", # pytest-parametrize-names-wrong-type
"PT007", # pytest-parametrize-values-wrong-type
"PT011", # pytest-raises-too-broad
"PT012", # pytest-raises-with-multiple-statements
"PT017", # pytest-assert-in-exceptinstead
"PT018", # pytest-composite-assertion
"PT022", # pytest-useless-yield-fixture
"PT023", # pytest-incorrect-mark-parentheses-style
# flake8-use-pathlib (PTH)
"PTH100", # os-path-abspath
"PTH101", # os-chmod
"PTH102", # os-mkdir
"PTH103", # os-makedirs
"PTH104", # os-rename
"PTH107", # os-remove
"PTH108", # os-unlink
"PTH109", # os-getcwd
"PTH110", # os-path-exists
"PTH111", # os-path-expanduser
"PTH112", # os-path-isdir
"PTH113", # os-path-isfile
"PTH118", # os-path-join
"PTH119", # os-path-basename
"PTH120", # os-path-dirname
"PTH122", # os-path-splitext
"PTH123", # builtin-open
"PTH202", # `os.path.getsize` should be replaced by `Path.stat().st_size`
"PTH207", # Replace `glob` with `Path.glob` or `Path.rglob`
# flake8-return (RET)
"RET501", # unnecessary-return-none
"RET502", # implicit-return-value
"RET503", # implicit-return
"RET504", # unnecessary-assign
"RET505", # superfluous-else-return
"RET507", # superfluous-else-continue
# flake8-raise (RSE)
"RSE102", # unnecessary-paren-on-raise-exception
# Ruff-specific rules (RUF)
"RUF001", # ambiguous-unicode-character-string
"RUF002", # ambiguous-unicode-character-docstring
"RUF010", # use conversion in f-string
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
# flake8-bandit (S)
"S101", # Use of `assert` detected
"S105", # hardcoded-password-string
"S110", # try-except-pass
"S112", # try-except-continue
"S301", # suspicious-pickle-usage
"S307", # Use of possibly insecure function; consider using `ast.literal_eval`
"S311", # suspicious-non-cryptographic-randomness
"S324", # hashlib-insecure-hash-function
"S506", # UnsafeYAMLLoad
"S310", # Suspicious-url-open-usage
"S603", # `subprocess` call: check for execution of untrusted input
"S607", # Starting a process with a partial executable path
# flake8-simplify (SIM)
"SIM102", # NestedIfStatements
"SIM105", # UseContextlibSuppress
"SIM108", # UseTernaryOperator
"SIM114", # if-with-same-arms
"SIM115", # OpenFileWithContextHandler
"SIM117", # MultipleWithStatements
"SIM118", # KeyInDict
"SIM201", # NegateEqualOp
"SIM300", # yoda condition
# flake8-print (T20)
"T201", # PrintUsed
# flake8-todos (TD)
"TD001", # Invalid TODO tag
"TD003", # Missing issue link on the line following this TODO
"TD004", # Missing colon in TODO
"TD007", # Missing space after colon in TODO
# tryceratops (TRY)
"TRY002", # raise-vanilla-class
"TRY003", # raise-vanilla-args
"TRY004", # prefer-type-error
"TRY200", # reraise-no-cause
"TRY201", # verbose-raise
"TRY300", # Consider `else` block
"TRY301", # raise-within-try
# flake8-quotes (Q)
"Q000", # use double quotes
]
lint.unfixable = [
"E711" # NoneComparison. Hard to fix b/c numpy has it's own None.
]
[lint.extend-per-file-ignores]
"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = [
"RUF015", # Prefer next({iterable}) over single element slice
]
# TODO: fix these, on a per-subpackage basis.
# When a general exclusion is being fixed, but it affects many subpackages, it
# is better to fix for subpackages individually. The general exclusion should be
# copied to these subpackage sections and fixed there.
"astropy/__init__.py" = ["C408"]
"astropy/config/*" = [
"PTH114", # os-path-islink
"PTH206", # Replace `.split(os.sep)` with `Path.parts`
"RET506", # superfluous-else-raise
]
"astropy/constants/*" = ["N817"] # camelcase-imported-as-acronym
"astropy/convolution/*" = [
"RET506", # superfluous-else-raise
]
"astropy/coordinates/*" = [
"DTZ007", # call-datetime-strptime-without-zone
]
"astropy/cosmology/*" = [
"C408", # unnecessary-collection-call
"PT019", # pytest-fixture-param-without-value
"RET506", # superfluous-else-raise
]
"astropy/io/*" = [
"G001", # logging-string-format
"G004", # logging-f-string
"PTH116", # os-stat
"PTH117", # os-path-isabs
"RET506", # superfluous-else-raise
"SLOT000", # Subclasses of `str` should define `__slots__`
"TD005", # Missing issue description after `TODO`
"TRY400", # error-instead-of-exception
]
"astropy/logger.py" = ["C408"]
"astropy/modeling/*" = [
"C408", # unnecessary-collection-call
"RET506", # superfluous-else-raise
"SLOT001", # Subclasses of `tuple` should define `__slots__`
]
"astropy/nddata/*" = [
"C408",
"RET506", # superfluous-else-raise
]
"astropy/samp/*" = [
"RET506", # superfluous-else-raise
]
"astropy/stats/*" = [
"RET506", # superfluous-else-raise
]
"astropy/table/*" = [
"C408", # unnecessary-collection-call
"RET506", # superfluous-else-raise
"S605", # Starting a process with a shell, possible injection detected
]
"astropy/tests/*" = ["C408"]
"astropy/time/*" = [
"C408", # unnecessary-collection-call
"FIX003", # Line contains XXX. replace XXX with TODO
"PIE794", # duplicate-class-field-definition
"RET506", # superfluous-else-raise
]
"astropy/timeseries/*" = [
"C408",
"RET506", # superfluous-else-raise
]
"astropy/units/*" = [
"C408", # unnecessary-collection-call
"F821", # undefined-name
"N812", # lowercase-imported-as-non-lowercase
"RET506", # superfluous-else-raise
]
"astropy/uncertainty/*" = [
"C408",
"RET506", # superfluous-else-raise
]
"astropy/utils/*" = [
"C408", # unnecessary-collection-call
"N811", # constant-imported-as-non-constant
"RET506", # superfluous-else-raise
"S321", # Suspicious-ftp-lib-usage
]
"astropy/visualization/*" = [
"B015",
"C408",
"RET506", # superfluous-else-raise
]
"astropy/wcs/*" = [
"C408", # unnecessary-collection-call
"F821", # undefined-name
"S608", # Posslibe SQL injection
"RET506", # superfluous-else-raise
"SIM202", # NegateNotEqualOp
]
"docs/*" = []
"examples/coordinates/*" = []