breakpoint() drops you into the debugger where the bug is
One builtin call, no import, and PYTHONBREAKPOINT=0 disables every one of them in production.
def apply_discount(order):
breakpoint()
...Inspect locals, step, evaluate expressions against the live state. Set PYTHONBREAKPOINT=ipdb.set_trace for a nicer one if it is installed.
pythondebugging