Skip to content

Feature request: Support UUID data type #279

@havardthom

Description

@havardthom

Would love support for UUID data type. Current situation:

import pprint
import uuid

from deepdiff import DeepDiff

t1 = {"id": uuid.uuid4()}
t2 = {"id": uuid.uuid4()}

result = DeepDiff(t1, t2)

pprint.pprint(result)

{'values_changed': {"root['id'].int": {'new_value': 117850254076634266241219085205683222228,
                                       'old_value': 91358784609380289177662098655200634313}}}

This causes problems for me since an unexpected int is appended to path, and dumping result as json will crash due to Integer exceeds 64-bit range. Would be great if result could rather be something like:

{'values_changed': {"root['id']": {'new_value': UUID(...),
                                   'old_value': UUID(...)}}}

I've added exclude_types={UUID} to work around my problems for now.

Docs mentions support for custom objects, but I didn't find any examples

Supported data types
int, string, unicode, dictionary, list, tuple, set, frozenset, OrderedDict, NamedTuple, Numpy, custom objects and more!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions