---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E712.py:2:4: E712 [*] Avoid equality comparisons to `True`; use `if res:` for truth checks
  |
1 | #: E712
2 | if res == True:
  |    ^^^^^^^^^^^ E712
3 |     pass
4 | #: E712
  |
  = help: Replace with `res`

ℹ Unsafe fix
1 1 | #: E712
2   |-if res == True:
  2 |+if res is True:
3 3 |     pass
4 4 | #: E712
5 5 | if res != False:

E712.py:5:4: E712 [*] Avoid inequality comparisons to `False`; use `if res:` for truth checks
  |
3 |     pass
4 | #: E712
5 | if res != False:
  |    ^^^^^^^^^^^^ E712
6 |     pass
7 | #: E712
  |
  = help: Replace with `res`

ℹ Unsafe fix
2 2 | if res == True:
3 3 |     pass
4 4 | #: E712
5   |-if res != False:
  5 |+if res is not False:
6 6 |     pass
7 7 | #: E712
8 8 | if True != res:

E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `if not res:` for false checks
   |
 6 |     pass
 7 | #: E712
 8 | if True != res:
   |    ^^^^^^^^^^^ E712
 9 |     pass
10 | #: E712
   |
   = help: Replace with `not res`

ℹ Unsafe fix
5 5 | if res != False:
6 6 |     pass
7 7 | #: E712
8   |-if True != res:
  8 |+if True is not res:
9 9 |     pass
10 10 | #: E712
11 11 | if False == res:

E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `if not res:` for false checks
   |
 9 |     pass
10 | #: E712
11 | if False == res:
   |    ^^^^^^^^^^^^ E712
12 |     pass
13 | #: E712
   |
   = help: Replace with `not res`

ℹ Unsafe fix
8  8  | if True != res:
9  9  |     pass
10 10 | #: E712
11    |-if False == res:
   11 |+if False is res:
12 12 |     pass
13 13 | #: E712
14 14 | if res[1] == True:

E712.py:14:4: E712 [*] Avoid equality comparisons to `True`; use `if res[1]:` for truth checks
   |
12 |     pass
13 | #: E712
14 | if res[1] == True:
   |    ^^^^^^^^^^^^^^ E712
15 |     pass
16 | #: E712
   |
   = help: Replace with `res[1]`

ℹ Unsafe fix
11 11 | if False == res:
12 12 |     pass
13 13 | #: E712
14    |-if res[1] == True:
   14 |+if res[1] is True:
15 15 |     pass
16 16 | #: E712
17 17 | if res[1] != False:

E712.py:17:4: E712 [*] Avoid inequality comparisons to `False`; use `if res[1]:` for truth checks
   |
15 |     pass
16 | #: E712
17 | if res[1] != False:
   |    ^^^^^^^^^^^^^^^ E712
18 |     pass
19 | #: E712
   |
   = help: Replace with `res[1]`

ℹ Unsafe fix
14 14 | if res[1] == True:
15 15 |     pass
16 16 | #: E712
17    |-if res[1] != False:
   17 |+if res[1] is not False:
18 18 |     pass
19 19 | #: E712
20 20 | var = 1 if cond == True else -1 if cond == False else cond

E712.py:20:12: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks
   |
18 |     pass
19 | #: E712
20 | var = 1 if cond == True else -1 if cond == False else cond
   |            ^^^^^^^^^^^^ E712
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |
   = help: Replace with `cond`

ℹ Unsafe fix
17 17 | if res[1] != False:
18 18 |     pass
19 19 | #: E712
20    |-var = 1 if cond == True else -1 if cond == False else cond
   20 |+var = 1 if cond is True else -1 if cond == False else cond
21 21 | #: E712
22 22 | if (True) == TrueElement or x == TrueElement:
23 23 |     pass

E712.py:20:36: E712 [*] Avoid equality comparisons to `False`; use `if not cond:` for false checks
   |
18 |     pass
19 | #: E712
20 | var = 1 if cond == True else -1 if cond == False else cond
   |                                    ^^^^^^^^^^^^^ E712
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |
   = help: Replace with `not cond`

ℹ Unsafe fix
17 17 | if res[1] != False:
18 18 |     pass
19 19 | #: E712
20    |-var = 1 if cond == True else -1 if cond == False else cond
   20 |+var = 1 if cond == True else -1 if cond is False else cond
21 21 | #: E712
22 22 | if (True) == TrueElement or x == TrueElement:
23 23 |     pass

E712.py:22:4: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement:` for truth checks
   |
20 | var = 1 if cond == True else -1 if cond == False else cond
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |    ^^^^^^^^^^^^^^^^^^^^^ E712
23 |     pass
   |
   = help: Replace with `TrueElement`

ℹ Unsafe fix
19 19 | #: E712
20 20 | var = 1 if cond == True else -1 if cond == False else cond
21 21 | #: E712
22    |-if (True) == TrueElement or x == TrueElement:
   22 |+if (True) is TrueElement or x == TrueElement:
23 23 |     pass
24 24 | 
25 25 | if res == True != False:

E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False`
   |
23 |     pass
24 | 
25 | if res == True != False:
   |    ^^^^^^^^^^^^^^^^^^^^ E712
26 |     pass
   |
   = help: Replace comparison

ℹ Unsafe fix
22 22 | if (True) == TrueElement or x == TrueElement:
23 23 |     pass
24 24 | 
25    |-if res == True != False:
   25 |+if res is True is not False:
26 26 |     pass
27 27 | 
28 28 | if(True) == TrueElement or x == TrueElement:

E712.py:25:4: E712 [*] Avoid equality comparisons to `True` or `False`
   |
23 |     pass
24 | 
25 | if res == True != False:
   |    ^^^^^^^^^^^^^^^^^^^^ E712
26 |     pass
   |
   = help: Replace comparison

ℹ Unsafe fix
22 22 | if (True) == TrueElement or x == TrueElement:
23 23 |     pass
24 24 | 
25    |-if res == True != False:
   25 |+if res is True is not False:
26 26 |     pass
27 27 | 
28 28 | if(True) == TrueElement or x == TrueElement:

E712.py:28:3: E712 [*] Avoid equality comparisons to `True`; use `if TrueElement:` for truth checks
   |
26 |     pass
27 | 
28 | if(True) == TrueElement or x == TrueElement:
   |   ^^^^^^^^^^^^^^^^^^^^^ E712
29 |     pass
   |
   = help: Replace with `TrueElement`

ℹ Unsafe fix
25 25 | if res == True != False:
26 26 |     pass
27 27 | 
28    |-if(True) == TrueElement or x == TrueElement:
   28 |+if(True) is TrueElement or x == TrueElement:
29 29 |     pass
30 30 | 
31 31 | if (yield i) == True:

E712.py:31:4: E712 [*] Avoid equality comparisons to `True`; use `if yield i:` for truth checks
   |
29 |     pass
30 | 
31 | if (yield i) == True:
   |    ^^^^^^^^^^^^^^^^^ E712
32 |       print("even")
   |
   = help: Replace with `yield i`

ℹ Unsafe fix
28 28 | if(True) == TrueElement or x == TrueElement:
29 29 |     pass
30 30 | 
31    |-if (yield i) == True:
   31 |+if (yield i) is True:
32 32 |       print("even")
33 33 | 
34 34 | #: Okay
