Replaced most assertions in favor of error handling
assert
statements can be disabled with python's -O
flag (from Python's help: -O : remove assert and __debug__-dependent statements [...]
), so they are not suited for flow-control or plausibility checks. That's also in line with other programming languages. Therefore I replaced most assert
checks with proper if
-statements.
I left assertions in the pytest files and where I think they help with understanding the state or purpose of a variable.
Edited by Karsten Prehn