-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Tweak E712
docs
#8613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak E712
docs
#8613
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs | ||
--- | ||
E712.py:2:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` | ||
E712.py:2:11: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
1 | #: E712 | ||
2 | if res == True: | ||
| ^^^^ E712 | ||
3 | pass | ||
4 | #: E712 | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's possibly outside the scope of this PR (you can leave it for now, if you like), but this suggestion is pretty confusing. There's no variable named "cond" in scope here, and I don't think it's obvious that this means "replace |
||
|
||
ℹ Unsafe fix | ||
1 1 | #: E712 | ||
|
@@ -19,7 +19,7 @@ E712.py:2:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond | |
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:` | ||
E712.py:5:11: E712 [*] Avoid inequality comparisons to `False`; use `if cond:` for truth checks | ||
| | ||
3 | pass | ||
4 | #: E712 | ||
|
@@ -28,7 +28,7 @@ E712.py:5:11: E712 [*] Comparison to `False` should be `cond is not False` or `i | |
6 | pass | ||
7 | #: E712 | ||
| | ||
= help: Replace with `cond is not False` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
2 2 | if res == True: | ||
|
@@ -40,7 +40,7 @@ E712.py:5:11: E712 [*] Comparison to `False` should be `cond is not False` or `i | |
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:` | ||
E712.py:8:4: E712 [*] Avoid inequality comparisons to `True`; use `if not cond:` for false checks | ||
| | ||
6 | pass | ||
7 | #: E712 | ||
|
@@ -49,7 +49,7 @@ E712.py:8:4: E712 [*] Comparison to `True` should be `cond is not True` or `if n | |
9 | pass | ||
10 | #: E712 | ||
| | ||
= help: Replace with `cond is not True` | ||
= help: Replace with `not cond` | ||
|
||
ℹ Unsafe fix | ||
5 5 | if res != False: | ||
|
@@ -61,7 +61,7 @@ E712.py:8:4: E712 [*] Comparison to `True` should be `cond is not True` or `if n | |
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:` | ||
E712.py:11:4: E712 [*] Avoid equality comparisons to `False`; use `if not cond:` for false checks | ||
| | ||
9 | pass | ||
10 | #: E712 | ||
|
@@ -70,7 +70,7 @@ E712.py:11:4: E712 [*] Comparison to `False` should be `cond is False` or `if no | |
12 | pass | ||
13 | #: E712 | ||
| | ||
= help: Replace with `cond is False` | ||
= help: Replace with `not cond` | ||
|
||
ℹ Unsafe fix | ||
8 8 | if True != res: | ||
|
@@ -82,7 +82,7 @@ E712.py:11:4: E712 [*] Comparison to `False` should be `cond is False` or `if no | |
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:` | ||
E712.py:14:14: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
12 | pass | ||
13 | #: E712 | ||
|
@@ -91,7 +91,7 @@ E712.py:14:14: E712 [*] Comparison to `True` should be `cond is True` or `if con | |
15 | pass | ||
16 | #: E712 | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
11 11 | if False == res: | ||
|
@@ -103,7 +103,7 @@ E712.py:14:14: E712 [*] Comparison to `True` should be `cond is True` or `if con | |
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:` | ||
E712.py:17:14: E712 [*] Avoid inequality comparisons to `False`; use `if cond:` for truth checks | ||
| | ||
15 | pass | ||
16 | #: E712 | ||
|
@@ -112,7 +112,7 @@ E712.py:17:14: E712 [*] Comparison to `False` should be `cond is not False` or ` | |
18 | pass | ||
19 | #: E712 | ||
| | ||
= help: Replace with `cond is not False` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
14 14 | if res[1] == True: | ||
|
@@ -124,7 +124,7 @@ E712.py:17:14: E712 [*] Comparison to `False` should be `cond is not False` or ` | |
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:` | ||
E712.py:20:20: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
18 | pass | ||
19 | #: E712 | ||
|
@@ -133,7 +133,7 @@ E712.py:20:20: E712 [*] Comparison to `True` should be `cond is True` or `if con | |
21 | #: E712 | ||
22 | if (True) == TrueElement or x == TrueElement: | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
17 17 | if res[1] != False: | ||
|
@@ -145,7 +145,7 @@ E712.py:20:20: E712 [*] Comparison to `True` should be `cond is True` or `if con | |
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:` | ||
E712.py:20:44: E712 [*] Avoid equality comparisons to `False`; use `if not cond:` for false checks | ||
| | ||
18 | pass | ||
19 | #: E712 | ||
|
@@ -154,7 +154,7 @@ E712.py:20:44: E712 [*] Comparison to `False` should be `cond is False` or `if n | |
21 | #: E712 | ||
22 | if (True) == TrueElement or x == TrueElement: | ||
| | ||
= help: Replace with `cond is False` | ||
= help: Replace with `not cond` | ||
|
||
ℹ Unsafe fix | ||
17 17 | if res[1] != False: | ||
|
@@ -166,15 +166,15 @@ E712.py:20:44: E712 [*] Comparison to `False` should be `cond is False` or `if n | |
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:` | ||
E712.py:22:5: E712 [*] Avoid equality comparisons to `True`; use `if cond:` 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 `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
19 19 | #: E712 | ||
|
@@ -186,15 +186,15 @@ E712.py:22:5: E712 [*] Comparison to `True` should be `cond is True` or `if cond | |
24 24 | | ||
25 25 | if res == True != False: | ||
|
||
E712.py:25:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` | ||
E712.py:25:11: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
23 | pass | ||
24 | | ||
25 | if res == True != False: | ||
| ^^^^ E712 | ||
26 | pass | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
22 22 | if (True) == TrueElement or x == TrueElement: | ||
|
@@ -206,15 +206,15 @@ E712.py:25:11: E712 [*] Comparison to `True` should be `cond is True` or `if con | |
27 27 | | ||
28 28 | if(True) == TrueElement or x == TrueElement: | ||
|
||
E712.py:25:19: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` | ||
E712.py:25:19: E712 [*] Avoid inequality comparisons to `False`; use `if cond:` for truth checks | ||
| | ||
23 | pass | ||
24 | | ||
25 | if res == True != False: | ||
| ^^^^^ E712 | ||
26 | pass | ||
| | ||
= help: Replace with `cond is not False` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
22 22 | if (True) == TrueElement or x == TrueElement: | ||
|
@@ -226,15 +226,15 @@ E712.py:25:19: E712 [*] Comparison to `False` should be `cond is not False` or ` | |
27 27 | | ||
28 28 | if(True) == TrueElement or x == TrueElement: | ||
|
||
E712.py:28:4: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` | ||
E712.py:28:4: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
26 | pass | ||
27 | | ||
28 | if(True) == TrueElement or x == TrueElement: | ||
| ^^^^ E712 | ||
29 | pass | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
25 25 | if res == True != False: | ||
|
@@ -246,15 +246,15 @@ E712.py:28:4: E712 [*] Comparison to `True` should be `cond is True` or `if cond | |
30 30 | | ||
31 31 | if (yield i) == True: | ||
|
||
E712.py:31:17: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` | ||
E712.py:31:17: E712 [*] Avoid equality comparisons to `True`; use `if cond:` for truth checks | ||
| | ||
29 | pass | ||
30 | | ||
31 | if (yield i) == True: | ||
| ^^^^ E712 | ||
32 | print("even") | ||
| | ||
= help: Replace with `cond is True` | ||
= help: Replace with `cond` | ||
|
||
ℹ Unsafe fix | ||
28 28 | if(True) == TrueElement or x == TrueElement: | ||
|
Uh oh!
There was an error while loading. Please reload this page.