1
1
-- -
2
2
source : crates / ruff_linter / src / rules / pylint / mod .rs
3
3
-- -
4
- repeated_equality_comparison .py :2 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b") ` . Use a ` set ` if the elements are hashable .
4
+ repeated_equality_comparison .py :2 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" } ` .
5
5
|
6
6
1 | # Errors .
7
7
2 | foo == " a" or foo == " b"
@@ -14,12 +14,12 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa
14
14
ℹ Unsafe fix
15
15
1 1 | # Errors .
16
16
2 | - foo == " a" or foo == " b"
17
- 2 | + foo in ( " a" , " b" )
17
+ 2 | + foo in { "a", "b"}
18
18
3 3 |
19
19
4 4 | foo != " a" and foo != " b"
20
20
5 5 |
21
21
22
- repeated_equality_comparison .py :4 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in ( "a", "b") ` . Use a ` set ` if the elements are hashable .
22
+ repeated_equality_comparison .py :4 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in { " a" , " b" } ` .
23
23
|
24
24
2 | foo == " a" or foo == " b"
25
25
3 |
@@ -35,12 +35,12 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa
35
35
2 2 | foo == " a" or foo == " b"
36
36
3 3 |
37
37
4 | - foo != " a" and foo != " b"
38
- 4 | + foo not in ( " a" , " b" )
38
+ 4 | + foo not in { "a", "b"}
39
39
5 5 |
40
40
6 6 | foo == " a" or foo == " b" or foo == " c"
41
41
7 7 |
42
42
43
- repeated_equality_comparison .py :6 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
43
+ repeated_equality_comparison .py :6 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" , " c" } ` .
44
44
|
45
45
4 | foo != " a" and foo != " b"
46
46
5 |
@@ -56,12 +56,12 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa
56
56
4 4 | foo != " a" and foo != " b"
57
57
5 5 |
58
58
6 | - foo == " a" or foo == " b" or foo == " c"
59
- 6 | + foo in ( " a" , " b" , " c" )
59
+ 6 | + foo in { "a", "b", "c"}
60
60
7 7 |
61
61
8 8 | foo != " a" and foo != " b" and foo != " c"
62
62
9 9 |
63
63
64
- repeated_equality_comparison .py :8 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
64
+ repeated_equality_comparison .py :8 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in { " a" , " b" , " c" } ` .
65
65
|
66
66
6 | foo == " a" or foo == " b" or foo == " c"
67
67
7 |
@@ -77,7 +77,7 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa
77
77
6 6 | foo == " a" or foo == " b" or foo == " c"
78
78
7 7 |
79
79
8 | - foo != " a" and foo != " b" and foo != " c"
80
- 8 | + foo not in ( " a" , " b" , " c" )
80
+ 8 | + foo not in { "a", "b", "c"}
81
81
9 9 |
82
82
10 10 | foo == a or foo == " b" or foo == 3 # Mixed types .
83
83
11 11 |
@@ -103,7 +103,7 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp
103
103
12 12 | " a" == foo or " b" == foo or " c" == foo
104
104
13 13 |
105
105
106
- repeated_equality_comparison .py :12 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
106
+ repeated_equality_comparison .py :12 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" , " c" } ` .
107
107
|
108
108
10 | foo == a or foo == " b" or foo == 3 # Mixed types .
109
109
11 |
@@ -119,12 +119,12 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp
119
119
10 10 | foo == a or foo == " b" or foo == 3 # Mixed types .
120
120
11 11 |
121
121
12 | - " a" == foo or " b" == foo or " c" == foo
122
- 12 | + foo in ( " a" , " b" , " c" )
122
+ 12 | + foo in { "a", "b", "c"}
123
123
13 13 |
124
124
14 14 | " a" != foo and " b" != foo and " c" != foo
125
125
15 15 |
126
126
127
- repeated_equality_comparison .py :14 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
127
+ repeated_equality_comparison .py :14 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in { " a" , " b" , " c" } ` .
128
128
|
129
129
12 | " a" == foo or " b" == foo or " c" == foo
130
130
13 |
@@ -140,12 +140,12 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp
140
140
12 12 | " a" == foo or " b" == foo or " c" == foo
141
141
13 13 |
142
142
14 | - " a" != foo and " b" != foo and " c" != foo
143
- 14 | + foo not in ( " a" , " b" , " c" )
143
+ 14 | + foo not in { "a", "b", "c"}
144
144
15 15 |
145
145
16 16 | " a" == foo or foo == " b" or " c" == foo
146
146
17 17 |
147
147
148
- repeated_equality_comparison .py :16 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
148
+ repeated_equality_comparison .py :16 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" , " c" } ` .
149
149
|
150
150
14 | " a" != foo and " b" != foo and " c" != foo
151
151
15 |
@@ -161,7 +161,7 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp
161
161
14 14 | " a" != foo and " b" != foo and " c" != foo
162
162
15 15 |
163
163
16 | - " a" == foo or foo == " b" or " c" == foo
164
- 16 | + foo in ( " a" , " b" , " c" )
164
+ 16 | + foo in { "a", "b", "c"}
165
165
17 17 |
166
166
18 18 | foo == bar or baz == foo or qux == foo
167
167
19 19 |
@@ -187,7 +187,7 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp
187
187
20 20 | foo == " a" or " b" == foo or foo == " c"
188
188
21 21 |
189
189
190
- repeated_equality_comparison .py :20 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
190
+ repeated_equality_comparison .py :20 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" , " c" } ` .
191
191
|
192
192
18 | foo == bar or baz == foo or qux == foo
193
193
19 |
@@ -203,12 +203,12 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp
203
203
18 18 | foo == bar or baz == foo or qux == foo
204
204
19 19 |
205
205
20 | - foo == " a" or " b" == foo or foo == " c"
206
- 20 | + foo in ( " a" , " b" , " c" )
206
+ 20 | + foo in { "a", "b", "c"}
207
207
21 21 |
208
208
22 22 | foo != " a" and " b" != foo and foo != " c"
209
209
23 23 |
210
210
211
- repeated_equality_comparison .py :22 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in ( "a", "b", "c") ` . Use a ` set ` if the elements are hashable .
211
+ repeated_equality_comparison .py :22 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo not in { " a" , " b" , " c" } ` .
212
212
|
213
213
20 | foo == " a" or " b" == foo or foo == " c"
214
214
21 |
@@ -224,12 +224,12 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp
224
224
20 20 | foo == " a" or " b" == foo or foo == " c"
225
225
21 21 |
226
226
22 | - foo != " a" and " b" != foo and foo != " c"
227
- 22 | + foo not in ( " a" , " b" , " c" )
227
+ 22 | + foo not in { "a", "b", "c"}
228
228
23 23 |
229
229
24 24 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
230
230
25 25 |
231
231
232
- repeated_equality_comparison .py :24 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b") ` . Use a ` set ` if the elements are hashable .
232
+ repeated_equality_comparison .py :24 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" } ` .
233
233
|
234
234
22 | foo != " a" and " b" != foo and foo != " c"
235
235
23 |
@@ -245,12 +245,12 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp
245
245
22 22 | foo != " a" and " b" != foo and foo != " c"
246
246
23 23 |
247
247
24 | - foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
248
- 24 | + foo in ( " a" , " b" ) or " c" == bar or " d" == bar # Multiple targets
248
+ 24 | + foo in { "a", "b"} or " c" == bar or " d" == bar # Multiple targets
249
249
25 25 |
250
250
26 26 | foo .bar == " a" or foo .bar == " b" # Attributes .
251
251
27 27 |
252
252
253
- repeated_equality_comparison .py :24 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` bar in ( "c", "d") ` . Use a ` set ` if the elements are hashable .
253
+ repeated_equality_comparison .py :24 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` bar in { " c" , " d" } ` .
254
254
|
255
255
22 | foo != " a" and " b" != foo and foo != " c"
256
256
23 |
@@ -266,12 +266,12 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp
266
266
22 22 | foo != " a" and " b" != foo and foo != " c"
267
267
23 23 |
268
268
24 | - foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
269
- 24 | + foo == " a" or foo == " b" or bar in ( " c" , " d" ) # Multiple targets
269
+ 24 | + foo == " a" or foo == " b" or bar in { "c", "d"} # Multiple targets
270
270
25 25 |
271
271
26 26 | foo .bar == " a" or foo .bar == " b" # Attributes .
272
272
27 27 |
273
273
274
- repeated_equality_comparison .py :26 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo.bar in ( "a", "b") ` . Use a ` set ` if the elements are hashable .
274
+ repeated_equality_comparison .py :26 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo.bar in { " a" , " b" } ` .
275
275
|
276
276
24 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
277
277
25 |
@@ -287,12 +287,12 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp
287
287
24 24 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
288
288
25 25 |
289
289
26 | - foo .bar == " a" or foo .bar == " b" # Attributes .
290
- 26 | + foo .bar in ( " a" , " b" ) # Attributes .
290
+ 26 | + foo .bar in { "a", "b"} # Attributes .
291
291
27 27 |
292
292
28 28 | # OK
293
293
29 29 | foo == " a" and foo == " b" and foo == " c" # ` and` mixed with ` ==` .
294
294
295
- repeated_equality_comparison .py :61 :16 : PLR1714 [* ] Consider merging multiple comparisons : ` bar in ( "c", "d") ` . Use a ` set ` if the elements are hashable .
295
+ repeated_equality_comparison .py :61 :16 : PLR1714 [* ] Consider merging multiple comparisons : ` bar in { " c" , " d" } ` .
296
296
|
297
297
59 | foo == " a" or " c" == bar or foo == " b" or " d" == bar # Multiple targets
298
298
60 |
@@ -308,12 +308,12 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com
308
308
59 59 | foo == " a" or " c" == bar or foo == " b" or " d" == bar # Multiple targets
309
309
60 60 |
310
310
61 | - foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
311
- 61 | + foo == " a" or (bar in ( " c" , " d" ) ) or foo == " b" # Multiple targets
311
+ 61 | + foo == " a" or (bar in { "c", "d"} ) or foo == " b" # Multiple targets
312
312
62 62 |
313
313
63 63 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
314
314
64 64 |
315
315
316
- repeated_equality_comparison .py :63 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( "a", "b") ` . Use a ` set ` if the elements are hashable .
316
+ repeated_equality_comparison .py :63 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { " a" , " b" } ` .
317
317
|
318
318
61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
319
319
62 |
@@ -329,12 +329,12 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp
329
329
61 61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
330
330
62 62 |
331
331
63 | - foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
332
- 63 | + foo in ( " a" , " b" ) or " c" != bar and " d" != bar # Multiple targets
332
+ 63 | + foo in { "a", "b"} or " c" != bar and " d" != bar # Multiple targets
333
333
64 64 |
334
334
65 65 | foo == " a" or (" c" != bar and " d" != bar ) or foo == " b" # Multiple targets
335
335
66 66 |
336
336
337
- repeated_equality_comparison .py :63 :29 : PLR1714 [* ] Consider merging multiple comparisons : ` bar not in ( "c", "d") ` . Use a ` set ` if the elements are hashable .
337
+ repeated_equality_comparison .py :63 :29 : PLR1714 [* ] Consider merging multiple comparisons : ` bar not in { " c" , " d" } ` .
338
338
|
339
339
61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
340
340
62 |
@@ -350,12 +350,12 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com
350
350
61 61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
351
351
62 62 |
352
352
63 | - foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
353
- 63 | + foo == " a" or foo == " b" or bar not in ( " c" , " d" ) # Multiple targets
353
+ 63 | + foo == " a" or foo == " b" or bar not in { "c", "d"} # Multiple targets
354
354
64 64 |
355
355
65 65 | foo == " a" or (" c" != bar and " d" != bar ) or foo == " b" # Multiple targets
356
356
66 66 |
357
357
358
- repeated_equality_comparison .py :65 :16 : PLR1714 [* ] Consider merging multiple comparisons : ` bar not in ( "c", "d") ` . Use a ` set ` if the elements are hashable .
358
+ repeated_equality_comparison .py :65 :16 : PLR1714 [* ] Consider merging multiple comparisons : ` bar not in { " c" , " d" } ` .
359
359
|
360
360
63 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
361
361
64 |
@@ -371,12 +371,12 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com
371
371
63 63 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
372
372
64 64 |
373
373
65 | - foo == " a" or (" c" != bar and " d" != bar ) or foo == " b" # Multiple targets
374
- 65 | + foo == " a" or (bar not in ( " c" , " d" ) ) or foo == " b" # Multiple targets
374
+ 65 | + foo == " a" or (bar not in { "c", "d"} ) or foo == " b" # Multiple targets
375
375
66 66 |
376
376
67 67 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
377
377
68 68 |
378
378
379
- repeated_equality_comparison .py :69 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( 1, True) ` . Use a ` set ` if the elements are hashable .
379
+ repeated_equality_comparison .py :69 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { 1 , True } ` .
380
380
|
381
381
67 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
382
382
68 |
@@ -392,12 +392,12 @@ repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comp
392
392
67 67 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
393
393
68 68 |
394
394
69 | - foo == 1 or foo == True # Different types , same hashed value
395
- 69 | + foo in ( 1 , True ) # Different types , same hashed value
395
+ 69 | + foo in { 1, True } # Different types , same hashed value
396
396
70 70 |
397
397
71 71 | foo == 1 or foo == 1.0 # Different types , same hashed value
398
398
72 72 |
399
399
400
- repeated_equality_comparison .py :71 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( 1, 1.0) ` . Use a ` set ` if the elements are hashable .
400
+ repeated_equality_comparison .py :71 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { 1 , 1.0 } ` .
401
401
|
402
402
69 | foo == 1 or foo == True # Different types , same hashed value
403
403
70 |
@@ -413,12 +413,12 @@ repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comp
413
413
69 69 | foo == 1 or foo == True # Different types , same hashed value
414
414
70 70 |
415
415
71 | - foo == 1 or foo == 1.0 # Different types , same hashed value
416
- 71 | + foo in ( 1 , 1.0 ) # Different types , same hashed value
416
+ 71 | + foo in { 1, 1.0} # Different types , same hashed value
417
417
72 72 |
418
418
73 73 | foo == False or foo == 0 # Different types , same hashed value
419
419
74 74 |
420
420
421
- repeated_equality_comparison .py :73 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( False, 0) ` . Use a ` set ` if the elements are hashable .
421
+ repeated_equality_comparison .py :73 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { False , 0 } ` .
422
422
|
423
423
71 | foo == 1 or foo == 1.0 # Different types , same hashed value
424
424
72 |
@@ -434,11 +434,11 @@ repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comp
434
434
71 71 | foo == 1 or foo == 1.0 # Different types , same hashed value
435
435
72 72 |
436
436
73 | - foo == False or foo == 0 # Different types , same hashed value
437
- 73 | + foo in ( False , 0 ) # Different types , same hashed value
437
+ 73 | + foo in { False , 0} # Different types , same hashed value
438
438
74 74 |
439
439
75 75 | foo == 0.0 or foo == 0j # Different types , same hashed value
440
440
441
- repeated_equality_comparison .py :75 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in ( 0.0, 0j) ` . Use a ` set ` if the elements are hashable .
441
+ repeated_equality_comparison .py :75 :1 : PLR1714 [* ] Consider merging multiple comparisons : ` foo in { 0.0 , 0j } ` .
442
442
|
443
443
73 | foo == False or foo == 0 # Different types , same hashed value
444
444
74 |
@@ -452,4 +452,4 @@ repeated_equality_comparison.py:75:1: PLR1714 [*] Consider merging multiple comp
452
452
73 73 | foo == False or foo == 0 # Different types , same hashed value
453
453
74 74 |
454
454
75 | - foo == 0.0 or foo == 0j # Different types , same hashed value
455
- 75 | + foo in ( 0.0 , 0j ) # Different types , same hashed value
455
+ 75 | + foo in { 0.0, 0j } # Different types , same hashed value
0 commit comments