Open
Description
Platform: Python
Description of the false positive
assert
calls will be ignored when using the -O
option. Therefore some code shouldn't be considered as dead.
This is quite low priority. -O
related bugs are very common, but no one really uses it. Linters have been fighting forever to know whether this should be taken into account, or simply discarded
test.py
def hello():
assert False
return 1
print(hello())
Results:
python test.py
->AssertionError
python -O test.py
->1
-O
Remove assert statements and any code conditional on the value of __debug__. Augment the filename for compiled (bytecode) files by adding .opt-1 before the .pyc extension (see PEP 488). See also PYTHONOPTIMIZE.
URL to the alert on the project page on LGTM.com