Giter Site home page Giter Site logo

Comments (11)

seperman avatar seperman commented on July 16, 2024 2

Hello. Thank you for letting us know about why you need this feature. I am working on a plugin system for DeepDiff to allow easier customization of DeepDiff for such use cases. I will keep you posted. Thank you for your patience.

from deepdiff.

seperman avatar seperman commented on July 16, 2024

Interesting. I wonder whether this should be done by DeepDiff or it is a use case that should be done outside DeepDiff.

from deepdiff.

finnhughes avatar finnhughes commented on July 16, 2024

It would have been helpful for me saving me from having to do a bunch of unicode casts and worse some ugly BSON related casts in my tests when a python equality comparison is happy to ignore the type difference as long as the values match. Obviously it would have to be optional since DeepDiff being fussy about type is a great feature at other times.

from deepdiff.

phoebebright avatar phoebebright commented on July 16, 2024

I agree, particularly be able to ignore unicode vs. string optionally.

from deepdiff.

aexvir avatar aexvir commented on July 16, 2024

I also agree. I find necessary to compare dicts without comparing the types of the values

from deepdiff.

flomotlik avatar flomotlik commented on July 16, 2024

Any thoughts on this? Would definitely be helpful, happy to lend a hand if you have an implementation in mind.

from deepdiff.

itaykatz avatar itaykatz commented on July 16, 2024

I agree, first I'v thought that the exclude_type argument would satisfy this requirement but it totally excludes the validation process for any given item which applies to the given types.

from deepdiff.

wisotzky avatar wisotzky commented on July 16, 2024

Would like to add another use-case:
In dicts there are several ways to declare a key/value pair is unset. Examples could be: zero-length string, empty dictionary or NoneType. In those cases, I would like to have the option, that just the value change is reported but not the type change. Reasoning is, that during parsing a document and generating the dict - the parser might not know the data-type for unset values. So it would be best guess of the parser to use any of the implementations above. Deepdiff should have the option ignore such type changes (just in the case of unset values)...

Examples to encode <a/> (unset value) as a python dict:

x1 = {u'a': None}
x2 = {u'a': u''}
x3 = {u'a': {}}
x4 = {u'a': []}

To compare against:

z1={u'a': u'#myvalue#'}
z2={u'a': {u'b': u'c'}}

So instead of:

>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'type_changes': {"root['a']": {'new_type': <type 'unicode'>, 'old_type': <type 'NoneType'>, 'old_value': None, 'new_value': u'#myvalue#'}}}

Result should be:

>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'values_changed': {"root['a']": {'new_value': u'#myvalue#', 'old_value': None}}}

Alternatively of the tool might report:

>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'values_added': {"root['a']": u'#myvalue#'}}

from deepdiff.

nemani avatar nemani commented on July 16, 2024

I need this too! Can help if you need me to, too :)

I want to diff 2 objects, I just need the difference in values and not in the type.

from deepdiff.

ruiruige avatar ruiruige commented on July 16, 2024

sorry to comment in an old issue.
Is this feature supported?

from deepdiff.

seperman avatar seperman commented on July 16, 2024

Hi @kapilt @ruiruige @nemaniarjun @wisotzky @itaykatz @flomotlik @aexvir @phoebebright @finnhughes

We have ignore_type_in_groups now. I think that should solve most of the problems that are brought up in this ticket.

You can read about it here: https://deepdiff.readthedocs.io/en/latest/diff.html

Closing this ticket finally!

from deepdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.