---
source: crates/ruff/src/rules/pycodestyle/mod.rs
---
E712.py:2:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:`
  |
2 | #: E712
3 | if res == True:
  |           ^^^^ E712
4 |     pass
5 | #: E712
  |
  = help: Replace with `cond is True`

ℹ Suggested 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:11: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:`
  |
5 |     pass
6 | #: E712
7 | if res != False:
  |           ^^^^^ E712
8 |     pass
9 | #: E712
  |
  = help: Replace with `cond is not False`

ℹ Suggested 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 [*] Comparison to `True` should be `cond is not True` or `if not cond:`
   |
 8 |     pass
 9 | #: E712
10 | if True != res:
   |    ^^^^ E712
11 |     pass
12 | #: E712
   |
   = help: Replace with `cond is not True`

ℹ Suggested 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 [*] Comparison to `False` should be `cond is False` or `if not cond:`
   |
11 |     pass
12 | #: E712
13 | if False == res:
   |    ^^^^^ E712
14 |     pass
15 | #: E712
   |
   = help: Replace with `cond is False`

ℹ Suggested 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:14: E712 [*] Comparison to `True` should be `cond is True` or `if cond:`
   |
14 |     pass
15 | #: E712
16 | if res[1] == True:
   |              ^^^^ E712
17 |     pass
18 | #: E712
   |
   = help: Replace with `cond is True`

ℹ Suggested 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:14: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:`
   |
17 |     pass
18 | #: E712
19 | if res[1] != False:
   |              ^^^^^ E712
20 |     pass
21 | #: E712
   |
   = help: Replace with `cond is not False`

ℹ Suggested 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:20: E712 [*] Comparison to `True` should be `cond is True` or `if cond:`
   |
20 |     pass
21 | #: E712
22 | var = 1 if cond == True else -1 if cond == False else cond
   |                    ^^^^ E712
23 | #: E712
24 | if (True) == TrueElement or x == TrueElement:
   |
   = help: Replace with `cond is True`

ℹ Suggested 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:44: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:`
   |
20 |     pass
21 | #: E712
22 | var = 1 if cond == True else -1 if cond == False else cond
   |                                            ^^^^^ E712
23 | #: E712
24 | if (True) == TrueElement or x == TrueElement:
   |
   = help: Replace with `cond is False`

ℹ Suggested 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:5: E712 [*] Comparison to `True` should be `cond is True` or `if cond:`
   |
22 | var = 1 if cond == True else -1 if cond == False else cond
23 | #: E712
24 | if (True) == TrueElement or x == TrueElement:
   |     ^^^^ E712
25 |     pass
   |
   = help: Replace with `cond is True`

ℹ Suggested 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:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:`
   |
25 |     pass
26 | 
27 | if res == True != False:
   |           ^^^^ E712
28 |     pass
   |
   = help: Replace with `cond is True`

ℹ Suggested 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 | #: Okay

E712.py:25:19: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:`
   |
25 |     pass
26 | 
27 | if res == True != False:
   |                   ^^^^^ E712
28 |     pass
   |
   = help: Replace with `cond is not False`

ℹ Suggested 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 | #: Okay


