-
Notifications
You must be signed in to change notification settings - Fork 97
diff method doc string updates #137
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
base: master
Are you sure you want to change the base?
Conversation
dictdiffer/__init__.py
Outdated
| - Key/value pairs for 'add' and 'remove'; keys for lists are indexes | ||
| - Previous/new values for 'change', key being a part of the path in this case | ||
| - Several value tuples sharing the same op and path are wrapped in a | ||
| list, unless you specify `expand=True`, in which case they all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| list, unless you specify `expand=True`, in which case they all | |
| list, unless you specify `expand=True`, in which case they all |
| - Previous/new values for 'change', key being a part of the path in this case | ||
| - Several value tuples sharing the same op and path are wrapped in a | ||
| list, unless you specify `expand=True`, in which case they all | ||
| get a separate (op, path, values) tuple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| get a separate (op, path, values) tuple. | |
| get a separate (op, path, values) tuple. |
| - `path` is by default a dot-separated string of keys from the root of the | ||
| structure to the point of difference. | ||
| - If parameter `dot_notation` is set to False, path is a list of | ||
| separate key strings instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| separate key strings instead. | |
| separate key strings instead. |
|
@jirikuncar I guess you wanted to ping @mikaelho instead 😉 |
| {'_dictdiffer_value_key': {'type': 'datetime.date', 'value': '2021-07-06'}} | ||
| """ | ||
| transformed_value = False | ||
| for cls, transform in TRANSFORMS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a big fun of global variables. Would it be possible to pass transformations as parameters to diff function and propagate them down? I am afraid that the performance will suffer for "dict"-only cases since you will always iterate through this list.
| def add_transform(value_sample, represent, reconstruct): | ||
| TRANSFORMS.append((type(value_sample), {'from': represent, 'to': reconstruct})) | ||
| assert reconstruct(represent(value_sample)) == value_sample, ( | ||
| f'Could not reconstruct ({type(represent(value_sample)).__name__}) {represent(value_sample)} ' | ||
| f'to ({type(value_sample).__name__}) {value_sample}' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be avoided by allowing users to pass own list with transformations.
| def allow_import(*module_names): | ||
| for module in module_names: | ||
| importlib.import_module(module) | ||
| ALLOW_IMPORT.extend(module_names) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar reasoning as TRANSFORMS
| if isinstance(value, list): | ||
| key = int(key) | ||
| value = value[key] | ||
| value = value.__dict__ if key == '__dict__' else value[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| value = value.__dict__ if key == '__dict__' else value[key] | |
| try: | |
| value = value[key] | |
| except KeyError: | |
| if key == '__dict__': | |
| value = value.__dict__ | |
| else: | |
| raise |
dictdiffer/version.py
Outdated
| """Version information for dictdiffer package.""" | ||
|
|
||
| __version__ = '0.8.2.dev2+dirty' | ||
| __version__ = '0.6.2.dev32+dirty' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert
| assert patched_copy == reverted_in_place | ||
| patched_in_place = patch(changes, first, in_place=True) | ||
| assert first == patched_in_place | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
diff({'__dict__': {'a': 1}}, {'__dict__': {'a': 2}})
jirikuncar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comments and revert:
pytest.ini_disable → pytest.ini
As discussed earlier.