-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distinguish redundant-expr warnings from unreachable warnings
- Loading branch information
Showing
8 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- Type checker test cases for conditional checks that result in some | ||
-- expressions classified as redundant. | ||
|
||
[case testRedundantExpressions] | ||
# flags: --warn-redundant-expr | ||
def foo() -> bool: ... | ||
|
||
lst = [1, 2, 3, 4] | ||
|
||
b = False or foo() # E: Left operand of 'or' is always false | ||
c = True and foo() # E: Left operand of 'and' is always true | ||
g = 3 if True else 4 # E: If condition is always true | ||
h = 3 if False else 4 # E: If condition is always false | ||
i = [x for x in lst if True] # E: If condition in comprehension is always true | ||
j = [x for x in lst if False] # E: If condition in comprehension is always false | ||
k = [x for x in lst if isinstance(x, int) or foo()] # E: If condition in comprehension is always true | ||
[builtins fixtures/isinstancelist.pyi] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters