Skip to content
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

Regression test for make_simplified_union truthiness #15098

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,22 @@ j = [x for x in lst if False] # E: If condition in comprehension is a
k = [x for x in lst if isinstance(x, int) or foo()] # E: If condition in comprehension is always true [redundant-expr]
[builtins fixtures/isinstancelist.pyi]

[case testRedundantExprTruthiness]
# flags: --enable-error-code redundant-expr
from typing import List

def maybe() -> bool: ...

class Foo:
def __init__(self, x: List[int]) -> None:
self.x = x or []

def method(self) -> int:
if not self.x or maybe():
return 1
return 2
[builtins fixtures/list.pyi]

[case testNamedTupleNameMismatch]
from typing import NamedTuple

Expand Down