Skip to content

assert-false

Pythonsuspiciousno fixdefault: warn

Reports an assert whose test is the literal False, with or without a message.

assert statements are removed when Python runs with -O, so an assert False that is meant to stop the program does nothing there and execution goes on past the line.

To fix, write raise AssertionError(...), which always runs.

Reported
...
pass
assert False
assert False, "message"
assert 0
...
getattr(x, "__private")
...
python:
lint:
rules:
assert-false: warn # off, warn (default), error

Suppress one line with sudsy-disable-next-line assert-false in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff B011 full