deepdiff icon indicating copy to clipboard operation
deepdiff copied to clipboard

Add support for callable group_by

Open echan5 opened this issue 3 months ago • 4 comments

Hi, just discovered this package and it's the functionality I'm looking for! However, I have one minor proposal that would make it work better for my use case with a complex nested data structure, and that is to allow the group_by param to be a callable so that I can access the more nested layers.

I'm also fixing some issues that I ran into when I ran:

  1. python3 -m deepdiff.diff for the docstring examples,
  2. pytest due to missing dependencies

Note that I did run pytest and there were some failures but I think they were pre-existing as they also failed on the master branch, but without being familiar with the rest of the repo, please let me know if there might be any issues with this update!

I'm also not sure what the process is from here - this PR is merging into the dev branch.

echan5 avatar Sep 26 '25 17:09 echan5

@echan5 Thanks for the PR. What tests were failing and what is your environment? Tests are not failing on our CI so it must be your local env setup.

seperman avatar Sep 29 '25 20:09 seperman

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 96.08%. Comparing base (0978fb8) to head (9a673fe). :warning: Report is 8 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #571   +/-   ##
=======================================
  Coverage   96.07%   96.08%           
=======================================
  Files          16       16           
  Lines        4463     4465    +2     
=======================================
+ Hits         4288     4290    +2     
  Misses        175      175           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Sep 29 '25 20:09 codecov[bot]

You're right - it was my setup. It didn't originally occur to me how the dependencies of this repo are structured and I had just run uv sync --extra test (using python 3.12) before running uv run pytest tests (and adding any missing imports that came up like uv pip install numpy pytz click uuid6 pydantic and had gotten various assertion errors like the below (the list was actually much longer), which at first glance seemed to be discrepancies with spacing in strings:

FAILED tests/test_delta.py::TestBasicsOfDelta::test_delta_repr - assert '<Delta: {"iterable_item_added": {"root[2]": 3, "root[3]": 5}}>' in {'<Delta: {"iterable_item_added":{"root[2]":3,"root[3]":5}}>...

FAILED tests/test_summarize.py::TestSummarize::test_list_summary - assert '[100,101,102,103,10,"..."]' == '[100, 101, 1...3, 10, "..."]'

But I just examined more closely and realized I should re-install the environment with uv sync --all-extras and all the tests pass now. I'll also revert the changes I had put into pyproject.toml/uv.lock thinking they were to solve these dependency issues.

Please let me know if anything else needs addressing - thank you!

echan5 avatar Sep 30 '25 01:09 echan5

Hi @echan5 Thanks for the PR. Reviewing shortly.

seperman avatar Oct 13 '25 05:10 seperman