Checklist
Python's -O flag, enables "optimized mode" which, among other things, disables the assert statement. A naive user may activate it to try speed up their application. DRF has many uses of assert in its library code (not tests) to guard against bad conditions. Rewriting those assert statements as an if check and a raise of an appropriate exception would allow it to continue functioning in "optimized mode".
Checklist
Python's
-Oflag, enables "optimized mode" which, among other things, disables theassertstatement. A naive user may activate it to try speed up their application. DRF has many uses ofassertin its library code (not tests) to guard against bad conditions. Rewriting thoseassertstatements as anifcheck and araiseof an appropriate exception would allow it to continue functioning in "optimized mode".