11-- -
22source : crates / ruff_linter / src / rules / pylint / mod .rs
33-- -
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" } ` .
55 |
661 | # Errors .
772 | foo == " a" or foo == " b"
@@ -14,12 +14,12 @@ repeated_equality_comparison.py:2:1: PLR1714 [*] Consider merging multiple compa
1414ℹ Unsafe fix
15151 1 | # Errors .
16162 | - foo == " a" or foo == " b"
17- 2 | + foo in ( " a" , " b" )
17+ 2 | + foo in { "a", "b"}
18183 3 |
19194 4 | foo != " a" and foo != " b"
20205 5 |
2121
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" } ` .
2323 |
24242 | foo == " a" or foo == " b"
25253 |
@@ -35,12 +35,12 @@ repeated_equality_comparison.py:4:1: PLR1714 [*] Consider merging multiple compa
35352 2 | foo == " a" or foo == " b"
36363 3 |
37374 | - foo != " a" and foo != " b"
38- 4 | + foo not in ( " a" , " b" )
38+ 4 | + foo not in { "a", "b"}
39395 5 |
40406 6 | foo == " a" or foo == " b" or foo == " c"
41417 7 |
4242
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" } ` .
4444 |
45454 | foo != " a" and foo != " b"
46465 |
@@ -56,12 +56,12 @@ repeated_equality_comparison.py:6:1: PLR1714 [*] Consider merging multiple compa
56564 4 | foo != " a" and foo != " b"
57575 5 |
58586 | - foo == " a" or foo == " b" or foo == " c"
59- 6 | + foo in ( " a" , " b" , " c" )
59+ 6 | + foo in { "a", "b", "c"}
60607 7 |
61618 8 | foo != " a" and foo != " b" and foo != " c"
62629 9 |
6363
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" } ` .
6565 |
6666 6 | foo == " a" or foo == " b" or foo == " c"
6767 7 |
@@ -77,7 +77,7 @@ repeated_equality_comparison.py:8:1: PLR1714 [*] Consider merging multiple compa
77776 6 | foo == " a" or foo == " b" or foo == " c"
78787 7 |
79798 | - foo != " a" and foo != " b" and foo != " c"
80- 8 | + foo not in ( " a" , " b" , " c" )
80+ 8 | + foo not in { "a", "b", "c"}
81819 9 |
828210 10 | foo == a or foo == " b" or foo == 3 # Mixed types .
838311 11 |
@@ -103,7 +103,7 @@ repeated_equality_comparison.py:10:1: PLR1714 [*] Consider merging multiple comp
10310312 12 | " a" == foo or " b" == foo or " c" == foo
10410413 13 |
105105
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" } ` .
107107 |
10810810 | foo == a or foo == " b" or foo == 3 # Mixed types .
10910911 |
@@ -119,12 +119,12 @@ repeated_equality_comparison.py:12:1: PLR1714 [*] Consider merging multiple comp
11911910 10 | foo == a or foo == " b" or foo == 3 # Mixed types .
12012011 11 |
12112112 | - " a" == foo or " b" == foo or " c" == foo
122- 12 | + foo in ( " a" , " b" , " c" )
122+ 12 | + foo in { "a", "b", "c"}
12312313 13 |
12412414 14 | " a" != foo and " b" != foo and " c" != foo
12512515 15 |
126126
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" } ` .
128128 |
12912912 | " a" == foo or " b" == foo or " c" == foo
13013013 |
@@ -140,12 +140,12 @@ repeated_equality_comparison.py:14:1: PLR1714 [*] Consider merging multiple comp
14014012 12 | " a" == foo or " b" == foo or " c" == foo
14114113 13 |
14214214 | - " a" != foo and " b" != foo and " c" != foo
143- 14 | + foo not in ( " a" , " b" , " c" )
143+ 14 | + foo not in { "a", "b", "c"}
14414415 15 |
14514516 16 | " a" == foo or foo == " b" or " c" == foo
14614617 17 |
147147
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" } ` .
149149 |
15015014 | " a" != foo and " b" != foo and " c" != foo
15115115 |
@@ -161,7 +161,7 @@ repeated_equality_comparison.py:16:1: PLR1714 [*] Consider merging multiple comp
16116114 14 | " a" != foo and " b" != foo and " c" != foo
16216215 15 |
16316316 | - " a" == foo or foo == " b" or " c" == foo
164- 16 | + foo in ( " a" , " b" , " c" )
164+ 16 | + foo in { "a", "b", "c"}
16516517 17 |
16616618 18 | foo == bar or baz == foo or qux == foo
16716719 19 |
@@ -187,7 +187,7 @@ repeated_equality_comparison.py:18:1: PLR1714 [*] Consider merging multiple comp
18718720 20 | foo == " a" or " b" == foo or foo == " c"
18818821 21 |
189189
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" } ` .
191191 |
19219218 | foo == bar or baz == foo or qux == foo
19319319 |
@@ -203,12 +203,12 @@ repeated_equality_comparison.py:20:1: PLR1714 [*] Consider merging multiple comp
20320318 18 | foo == bar or baz == foo or qux == foo
20420419 19 |
20520520 | - foo == " a" or " b" == foo or foo == " c"
206- 20 | + foo in ( " a" , " b" , " c" )
206+ 20 | + foo in { "a", "b", "c"}
20720721 21 |
20820822 22 | foo != " a" and " b" != foo and foo != " c"
20920923 23 |
210210
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" } ` .
212212 |
21321320 | foo == " a" or " b" == foo or foo == " c"
21421421 |
@@ -224,12 +224,12 @@ repeated_equality_comparison.py:22:1: PLR1714 [*] Consider merging multiple comp
22422420 20 | foo == " a" or " b" == foo or foo == " c"
22522521 21 |
22622622 | - foo != " a" and " b" != foo and foo != " c"
227- 22 | + foo not in ( " a" , " b" , " c" )
227+ 22 | + foo not in { "a", "b", "c"}
22822823 23 |
22922924 24 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
23023025 25 |
231231
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" } ` .
233233 |
23423422 | foo != " a" and " b" != foo and foo != " c"
23523523 |
@@ -245,12 +245,12 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp
24524522 22 | foo != " a" and " b" != foo and foo != " c"
24624623 23 |
24724724 | - 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
24924925 25 |
25025026 26 | foo .bar == " a" or foo .bar == " b" # Attributes .
25125127 27 |
252252
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" } ` .
254254 |
25525522 | foo != " a" and " b" != foo and foo != " c"
25625623 |
@@ -266,12 +266,12 @@ repeated_equality_comparison.py:24:1: PLR1714 [*] Consider merging multiple comp
26626622 22 | foo != " a" and " b" != foo and foo != " c"
26726723 23 |
26826824 | - 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
27027025 25 |
27127126 26 | foo .bar == " a" or foo .bar == " b" # Attributes .
27227227 27 |
273273
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" } ` .
275275 |
27627624 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
27727725 |
@@ -287,12 +287,12 @@ repeated_equality_comparison.py:26:1: PLR1714 [*] Consider merging multiple comp
28728724 24 | foo == " a" or foo == " b" or " c" == bar or " d" == bar # Multiple targets
28828825 25 |
28928926 | - foo .bar == " a" or foo .bar == " b" # Attributes .
290- 26 | + foo .bar in ( " a" , " b" ) # Attributes .
290+ 26 | + foo .bar in { "a", "b"} # Attributes .
29129127 27 |
29229228 28 | # OK
29329329 29 | foo == " a" and foo == " b" and foo == " c" # ` and` mixed with ` ==` .
294294
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" } ` .
296296 |
29729759 | foo == " a" or " c" == bar or foo == " b" or " d" == bar # Multiple targets
29829860 |
@@ -308,12 +308,12 @@ repeated_equality_comparison.py:61:16: PLR1714 [*] Consider merging multiple com
30830859 59 | foo == " a" or " c" == bar or foo == " b" or " d" == bar # Multiple targets
30930960 60 |
31031061 | - 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
31231262 62 |
31331363 63 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
31431464 64 |
315315
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" } ` .
317317 |
31831861 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
31931962 |
@@ -329,12 +329,12 @@ repeated_equality_comparison.py:63:1: PLR1714 [*] Consider merging multiple comp
32932961 61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
33033062 62 |
33133163 | - 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
33333364 64 |
33433465 65 | foo == " a" or (" c" != bar and " d" != bar ) or foo == " b" # Multiple targets
33533566 66 |
336336
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" } ` .
338338 |
33933961 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
34034062 |
@@ -350,12 +350,12 @@ repeated_equality_comparison.py:63:29: PLR1714 [*] Consider merging multiple com
35035061 61 | foo == " a" or (" c" == bar or " d" == bar ) or foo == " b" # Multiple targets
35135162 62 |
35235263 | - 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
35435464 64 |
35535565 65 | foo == " a" or (" c" != bar and " d" != bar ) or foo == " b" # Multiple targets
35635666 66 |
357357
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" } ` .
359359 |
36036063 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
36136164 |
@@ -371,12 +371,12 @@ repeated_equality_comparison.py:65:16: PLR1714 [*] Consider merging multiple com
37137163 63 | foo == " a" or foo == " b" or " c" != bar and " d" != bar # Multiple targets
37237264 64 |
37337365 | - 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
37537566 66 |
37637667 67 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
37737768 68 |
378378
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 } ` .
380380 |
38138167 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
38238268 |
@@ -392,12 +392,12 @@ repeated_equality_comparison.py:69:1: PLR1714 [*] Consider merging multiple comp
39239267 67 | foo == " a" and " c" != bar or foo == " b" and " d" != bar # Multiple targets
39339368 68 |
39439469 | - 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
39639670 70 |
39739771 71 | foo == 1 or foo == 1.0 # Different types , same hashed value
39839872 72 |
399399
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 } ` .
401401 |
40240269 | foo == 1 or foo == True # Different types , same hashed value
40340370 |
@@ -413,12 +413,12 @@ repeated_equality_comparison.py:71:1: PLR1714 [*] Consider merging multiple comp
41341369 69 | foo == 1 or foo == True # Different types , same hashed value
41441470 70 |
41541571 | - 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
41741772 72 |
41841873 73 | foo == False or foo == 0 # Different types , same hashed value
41941974 74 |
420420
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 } ` .
422422 |
42342371 | foo == 1 or foo == 1.0 # Different types , same hashed value
42442472 |
@@ -434,11 +434,11 @@ repeated_equality_comparison.py:73:1: PLR1714 [*] Consider merging multiple comp
43443471 71 | foo == 1 or foo == 1.0 # Different types , same hashed value
43543572 72 |
43643673 | - 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
43843874 74 |
43943975 75 | foo == 0.0 or foo == 0j # Different types , same hashed value
440440
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 } ` .
442442 |
44344373 | foo == False or foo == 0 # Different types , same hashed value
44444474 |
@@ -452,4 +452,4 @@ repeated_equality_comparison.py:75:1: PLR1714 [*] Consider merging multiple comp
45245273 73 | foo == False or foo == 0 # Different types , same hashed value
45345374 74 |
45445475 | - 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