Adding a parameter to return command to enable returning custom object
I extensively use ipdb for debugging in the most strange situations, and many times I come across cases in which a specific function requires a predefined setup in prod to work as expected, which is hard to do during debugging.
In such cases I usually have to patch the mentioned function to behave as intended just to be able to continue debugging.
The suggestion is to add a parameter to the r(turn) command to patch the return value of the function. In this case, the current code will continue until returns, BUT it will return the INTENDED value.
150 def very_complex_setup(**kwargs):
151 # Make sure all dependencies are set up.
--> 152 result = other_setups(**kwargs)
153 return result
ipdb> injected_result = True
ipdb> return injected_result
This command is expected to ignore the result and instead return injected_result as the value of the very_complex_setup function.
I would suggest to try sthing like explained here: https://maurcz.github.io/posts/002-customizing-the-python-debugger/
Iow, I think that you can subclass ipdb yourself.