Skip to content

Commit 3cca987

Browse files
authored
Regression test for make_simplified_union truthiness (#15098)
Add a test for the code path exercised in #15094
1 parent 2a4c473 commit 3cca987

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/unit/check-errorcodes.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,22 @@ j = [x for x in lst if False] # E: If condition in comprehension is a
805805
k = [x for x in lst if isinstance(x, int) or foo()] # E: If condition in comprehension is always true [redundant-expr]
806806
[builtins fixtures/isinstancelist.pyi]
807807

808+
[case testRedundantExprTruthiness]
809+
# flags: --enable-error-code redundant-expr
810+
from typing import List
811+
812+
def maybe() -> bool: ...
813+
814+
class Foo:
815+
def __init__(self, x: List[int]) -> None:
816+
self.x = x or []
817+
818+
def method(self) -> int:
819+
if not self.x or maybe():
820+
return 1
821+
return 2
822+
[builtins fixtures/list.pyi]
823+
808824
[case testNamedTupleNameMismatch]
809825
from typing import NamedTuple
810826

0 commit comments

Comments
 (0)