Files
Morgan Bartholomew fa4b4eec34 [pycharm] PY-41827 check for union types in PySimplifyBooleanCheckInspection
to avoid ambiguous conditions


(cherry picked from commit f11c08f8dfea453a6676173bae57f96233429970)

IJ-MR-159379

GitOrigin-RevId: b700b1e5e7c077da7b61661d33c2a3aa135d9e21
2025-05-01 02:46:56 +00:00

37 lines
1.7 KiB
Python

if <weak_warning descr="Expression can be simplified">a == True</weak_warning>: ...
if a is True: ...
if a is False: ...
if a is not False: ...
if a is not True: ...
if <weak_warning descr="Expression can be simplified">a == []</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">a != []</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">b == False</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">c != True</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">d != False</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">a == False</weak_warning>: ...
# test in a non-boolean context
var = a is not True
# PY-6876
if a == 0: ...
# PY-42817
def f(b: bool, bn: bool | None, l: list, ln: list | None):
if <weak_warning descr="Expression can be simplified">False is b</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">False is not b</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">bn is True</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">bn is not True</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">bn == True</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">bn != True</weak_warning>: ...
if bn is False: ...
if False is bn: ...
if bn is not False: ...
if bn == False: ...
if bn != False: ...
if <weak_warning descr="Expression can be simplified">l == []</weak_warning>: ...
if <weak_warning descr="Expression can be simplified">l != []</weak_warning>: ...
if ln == []: ...
if ln != []: ...