Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty Difference output mode? #85

Closed
dbrrt opened this issue Sep 2, 2017 · 10 comments
Closed

Pretty Difference output mode? #85

dbrrt opened this issue Sep 2, 2017 · 10 comments

Comments

@dbrrt
Copy link

dbrrt commented Sep 2, 2017

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.

@dbrrt dbrrt changed the title a Pretty Difference output mode? Pretty Difference output mode? Sep 2, 2017
@seperman
Copy link
Owner

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

@simonfontana
Copy link

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.

@seperman
Copy link
Owner

seperman commented Apr 7, 2019

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.

@simonfontana
Copy link

simonfontana commented Apr 7, 2019

@seperman
That's probably better. I'll have a look and try it out. Thanks.

@seperman
Copy link
Owner

👍

@MKaras93
Copy link
Contributor

Hi @seperman is this still open?

@dbrrt
Copy link
Author

dbrrt commented Apr 10, 2020

@MKaras93 seems to be. Still a very desirable feature :)

@MKaras93
Copy link
Contributor

Reserved then, I will try to post a PR by the end of the weekend (maybe even today) :)

@seperman
Copy link
Owner

👍

@MKaras93 MKaras93 mentioned this issue Apr 20, 2020
@seperman
Copy link
Owner

Hi @dbrrt @MKaras93
DeepDiff 5 is released. Thanks to @MKaras93 for the PR.
https://zepworks.com/posts/deepdiff-5-released/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants