---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E712 [*] Avoid equality comparisons to `True`; use `res:` for truth checks
 --> E712.py:2:4
  |
1 | #: E712
2 | if res == True:
  |    ^^^^^^^^^^^
3 |     pass
4 | #: E712
  |
help: Replace with `res`
  |
1 | #: E712
  - if res == True:
2 + if res:
3 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid inequality comparisons to `False`; use `res:` for truth checks
 --> E712.py:5:4
  |
3 |     pass
4 | #: E712
5 | if res != False:
  |    ^^^^^^^^^^^^
6 |     pass
7 | #: E712
  |
help: Replace with `res`
  |
4 | #: E712
  - if res != False:
5 + if res:
6 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid inequality comparisons to `True`; use `not res:` for false checks
  --> E712.py:8:4
   |
 6 |     pass
 7 | #: E712
 8 | if True != res:
   |    ^^^^^^^^^^^
 9 |     pass
10 | #: E712
   |
help: Replace with `not res`
  |
7 | #: E712
  - if True != res:
8 + if not res:
9 |     pass
  |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `False`; use `not res:` for false checks
  --> E712.py:11:4
   |
 9 |     pass
10 | #: E712
11 | if False == res:
   |    ^^^^^^^^^^^^
12 |     pass
13 | #: E712
   |
help: Replace with `not res`
   |
10 | #: E712
   - if False == res:
11 + if not res:
12 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `res[1]:` for truth checks
  --> E712.py:14:4
   |
12 |     pass
13 | #: E712
14 | if res[1] == True:
   |    ^^^^^^^^^^^^^^
15 |     pass
16 | #: E712
   |
help: Replace with `res[1]`
   |
13 | #: E712
   - if res[1] == True:
14 + if res[1]:
15 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid inequality comparisons to `False`; use `res[1]:` for truth checks
  --> E712.py:17:4
   |
15 |     pass
16 | #: E712
17 | if res[1] != False:
   |    ^^^^^^^^^^^^^^^
18 |     pass
19 | #: E712
   |
help: Replace with `res[1]`
   |
16 | #: E712
   - if res[1] != False:
17 + if res[1]:
18 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `cond:` for truth checks
  --> E712.py:20:12
   |
18 |     pass
19 | #: E712
20 | var = 1 if cond == True else -1 if cond == False else cond
   |            ^^^^^^^^^^^^
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |
help: Replace with `cond`
   |
19 | #: E712
   - var = 1 if cond == True else -1 if cond == False else cond
20 + var = 1 if cond else -1 if cond == False else cond
21 | #: E712
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `False`; use `not cond:` for false checks
  --> E712.py:20:36
   |
18 |     pass
19 | #: E712
20 | var = 1 if cond == True else -1 if cond == False else cond
   |                                    ^^^^^^^^^^^^^
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |
help: Replace with `not cond`
   |
19 | #: E712
   - var = 1 if cond == True else -1 if cond == False else cond
20 + var = 1 if cond == True else -1 if not cond else cond
21 | #: E712
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks
  --> E712.py:22:4
   |
20 | var = 1 if cond == True else -1 if cond == False else cond
21 | #: E712
22 | if (True) == TrueElement or x == TrueElement:
   |    ^^^^^^^^^^^^^^^^^^^^^
23 |     pass
   |
help: Replace with `TrueElement`
   |
21 | #: E712
   - if (True) == TrueElement or x == TrueElement:
22 + if (TrueElement) or x == TrueElement:
23 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True` or `False`
  --> E712.py:25:4
   |
23 |     pass
24 |
25 | if res == True != False:
   |    ^^^^^^^^^^^^^^^^^^^^
26 |     pass
   |
help: Replace comparison
   |
24 |
   - if res == True != False:
25 + if res is True is not False:
26 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True` or `False`
  --> E712.py:25:4
   |
23 |     pass
24 |
25 | if res == True != False:
   |    ^^^^^^^^^^^^^^^^^^^^
26 |     pass
   |
help: Replace comparison
   |
24 |
   - if res == True != False:
25 + if res is True is not False:
26 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `TrueElement:` for truth checks
  --> E712.py:28:3
   |
26 |     pass
27 |
28 | if(True) == TrueElement or x == TrueElement:
   |   ^^^^^^^^^^^^^^^^^^^^^
29 |     pass
   |
help: Replace with `TrueElement`
   |
27 |
   - if(True) == TrueElement or x == TrueElement:
28 + if(TrueElement) or x == TrueElement:
29 |     pass
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `yield i:` for truth checks
  --> E712.py:31:4
   |
29 |     pass
30 |
31 | if (yield i) == True:
   |    ^^^^^^^^^^^^^^^^^
32 |       print("even")
   |
help: Replace with `yield i`
   |
30 |
   - if (yield i) == True:
31 + if (yield i):
32 |       print("even")
   |
note: This is an unsafe fix and may change runtime behavior

E712 [*] Avoid equality comparisons to `True`; use `True:` for truth checks
  --> E712.py:58:4
   |
57 | # https://github.com/astral-sh/ruff/issues/17582
58 | if True == True: # No duplicated diagnostic
   |    ^^^^^^^^^^^^
59 |     pass
   |
help: Replace with `True`
   |
57 | # https://github.com/astral-sh/ruff/issues/17582
   - if True == True: # No duplicated diagnostic
58 + if True: # No duplicated diagnostic
59 |     pass
   |
note: This is an unsafe fix and may change runtime behavior
