Pretty Difference output mode?
I was wondering if a pretty output wouldn't be a nice addon to the library. Something more human readable ?
For instance the below :
{'type_changes': {"root['a']['b']['c']": {'old_type': <type 'str'>, 'new_value': 42, 'old_value': 'foo', 'new_type': <type 'int'>}}}
could be replaced with something like :
type_changes for a.b.c, "foo" (string type) replaced by 42 (integer type)
Creating a wrapper for the library doesn't seem like the best way to overcome this, as a new update of the core library could break the wrapper.
Hi @dbrrt Sorry it took me more than a year to see this ticket. It is a cool idea. Not sure when I will have time to implement it though.
Would you be interested in making a PR for it?
Basically this is going to be another "view". We have the "text" view and "tree" view already. This can be the "pretty" view.
If you have time to make a PR for it, that would be great!
Thanks
Hi @seperman, I'm interested in creating a PR if I get the time. I was looking at the code a bit and noticed that TreeResult and TextResult are dictionaries. I think a pretty format should be returned as string. Do you think it would it be better to create method instead, pretty(), which returns a string? If we create a "pretty view" as you suggested and return it as string i think it would break consistency with current views and confuse users. If we return it as dict I don't think it would be pretty. I would like to hear your thoughts on this.
As for how the text should be printed I was thinking something like this: Value spec.replicas changed from 1 to 3 Value spec.template.spec.containers[0].image changed from alpine to ubuntu Type of spec.template.spec.containers[0].tag changed from float to string. Type of spec.template.spec.containers[1].tag changed from float to string and value changed from 0.1.0 to 0.2.0
I think this format will fit very nicely together with bdd tools such as behave and pytest-bdd.
Hi @simonfontana
Great points. You are right. We shouldn't make it as another view then. I like your idea. Maybe we can use the helper.short_repr function and the verbose parameter to have different variations of the pretty output. Sometimes what has changed is a big object and the pretty view probably just wants to show partial objects then.
@seperman That's probably better. I'll have a look and try it out. Thanks.
👍
Hi @seperman is this still open?
@MKaras93 seems to be. Still a very desirable feature :)
Reserved then, I will try to post a PR by the end of the weekend (maybe even today) :)
:+1:
Hi @dbrrt @MKaras93 DeepDiff 5 is released. Thanks to @MKaras93 for the PR. https://zepworks.com/posts/deepdiff-5-released/