cool-RR / PySnooper

Never use print for debugging again
MIT License
16.34k stars 951 forks source link

FEATURE REQUEST: Display value of *args, **kwargs in overridden save() #177

Closed DanielSwain closed 4 years ago

DanielSwain commented 4 years ago

We just came across an error in an overridden save() that was not present in the Django admin but that cropped up when creating a front-end with DRF. Turned out there was a kwarg that needed to have have its value changed: force_insert had to be changed to False because super was being called two times in the overridden save routine (yes, it had to be called two times in order to first save a file that was being uploaded). PySnooper DID show the value of kwargs when force_insert was explicitly set to False within the overridden save(), but it did NOT show the value of kwargs when the error occurred in the save() and the kwargs were not touched. If the value of kwargs had been shown automatically from within the save(), it would have been an immediate tipoff to how to remedy the error.

cool-RR commented 4 years ago

Interesting. I'd like to understand this but I'm a little confused. If you have a reproducible example, that'll help.

So the overridden save was calling the original save, right? Did you have depth >= 2 in order to have PySnooper track there?

Can you share the PySnooper output?

DanielSwain commented 4 years ago

Was not aware of depth >= 2. That provides what we need. Thanks for the quick response.

For reference, here is a Stack Overflow answer we found prior to trying PySnooper that helped us solve this problem. The person who asked the question had the same problem come up that we did because of calling super(Model, self).save(*args, **kwargs) two times in the overridden save().

cool-RR commented 4 years ago

Another day saved :joy: