Repository navigation
Conversation
number_to_string rebuilt complex numbers via "{real}+{imag}j".format(...).
When the imaginary part is negative this produced an invalid string like
"1.0+-1.0j", and the complex() round-trip raised ValueError -- so
number_to_string(1-1j) and, by extension, DeepHash(1-1j, significant_digits=3)
crashed. Join using the imaginary part's own sign instead.
- model.py: "comparision" -> "comparison" (DiffLevel.copy docstring) - diff.py: "revisted" -> "revisited" (TODO comment) - docstrings/view.rst: "representaion" -> "representation" (x2) - docstrings/deephash_doc.rst: "agains" -> "against"
DeepDiff([2], [2.0]) returned {} even though the scalar equivalent
DeepDiff(2, 2.0) and the dict equivalent DeepDiff({'a': 2}, {'a': 2.0})
both correctly report an int -> float type_change.
Root cause: for ordered iterables whose items are all basic-hashable,
DeepDiff diffs the two sequences with difflib.SequenceMatcher. Because
2 == 2.0 (and hash(2) == hash(2.0)), SequenceMatcher classifies the pair
as an 'equal' opcode, so the elements are never handed to _diff() -- the
only place the type-change check (get_type(t1) != get_type(t2)) lives.
The whole difference silently disappeared. The same happened for other
equal-but-differently-typed pairs such as [1] vs [Decimal(1)] and
[True] vs [1], and for changes buried among unchanged items, e.g.
[1, 2, 3] vs [1, 2.0, 3].
Fix: in the 'equal' opcode branch of _diff_ordered_iterable_by_difflib,
recurse into _diff() for any aligned pair whose types differ. Routing
through _diff() reuses the existing type-change logic, so all options are
honored automatically -- ignore_numeric_type_changes=True and
ignore_type_in_groups still suppress the report, and genuinely identical
items still produce nothing.
Added regression tests (fail before this change, pass after):
- [2] vs [2.0] reports the int -> float type_change and matches the
scalar result
- the change is detected among surrounding unchanged items
- ignore_numeric_type_changes=True still yields {}
Full test suite: 1251 passed, unchanged from baseline.
Fixes #605
The `deep` console script is always installed, but its dependencies (`click`, and `pyyaml` for YAML files) live in the optional `cli` extra. On a default install, running `deep` imported `deepdiff.commands`, which imports `click` at module load, so the command died with a bare `ModuleNotFoundError: No module named 'click'`. Point the entry point at a thin wrapper that checks for `click` first and exits with an actionable message (`pip install deepdiff[cli]`) instead of a traceback, keeping the CLI dependencies optional as intended. Fixes #594
`_dict_from_slots` unmangled each slot name using the concrete instance type (`type(object).__name__`). A mangled slot such as `__id` is stored under the name of the class that *declared* it (e.g. `_Parent__id`), so for a subclass instance the lookup used the wrong name (`_Child__id`), `hasattr` returned False, and the parent-defined slot was silently dropped. Pair each slot with the class in the MRO that declared it and unmangle using that class's name. Closes #506
Bumps [soupsieve](https://github.com/facelessuser/soupsieve) from 2.8.3 to 2.8.4. - [Release notes](https://github.com/facelessuser/soupsieve/releases) - [Commits](facelessuser/soupsieve@2.8.3...2.8.4) --- updated-dependencies: - dependency-name: soupsieve dependency-version: 2.8.4 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Delta serializes each iterable Opcode NamedTuple, then rebuilds it in the JSON deserializer with Opcode(**op_code), which assumes a mapping. That only holds under orjson: its default callback runs JSON_CONVERTOR and emits Opcodes as dicts. The stdlib json fallback (used on any install without the optional orjson extra) encodes NamedTuples natively as positional arrays, so Opcode(**op_code) raises TypeError and the documented round-trip Delta(dump, deserializer=json_loads) crashes for any list diff that goes through difflib opcodes (reorders / duplicates). Accept both shapes on deserialization: mapping -> Opcode(**op_code), array -> Opcode(*op_code) (fields are in NamedTuple order). Added a regression test that forces the builtin-json path via force_use_builtin_json=True so it guards the array shape even where orjson is installed.
fix: skip time truncation for date objects in truncate_datetime
…ive-imaginary Handle negative imaginary parts in number_to_string (#551)
Fix typos in docstrings and comments
Fix missing type changes for equal-comparing list items (#605)
fix(cli): give actionable error when 'deep' runs without cli extra (#594)
Fix mangled __slots__ attribute lost for subclass instances (#506)
Bump soupsieve from 2.8.3 to 2.8.4
Adds the two cases from the original fix that are not covered on dev: - 'e' notation with negative imaginary part (1.0e+0-1.0e+0j) - negative real with negative imaginary part (-1.0-1.0j) The code fix itself is already on dev via #598; this keeps only the extra test coverage. Targets dev, no CHANGELOG edit.
Replace the has_time check with a positive isinstance check so truncate_datetime only applies to datetime and time objects. This fixes the AttributeError when diffing timedelta values (timedelta has no .replace()) and avoids the same crash for np.datetime64 in DeepHash. Adds regression tests for timedelta and np.datetime64. Targets dev, no CHANGELOG edit.
Bumps [certifi](https://github.com/certifi/python-certifi) from 2026.4.22 to 2026.10.18. - [Commits](certifi/python-certifi@2026.04.22...2026.10.18) --- updated-dependencies: - dependency-name: certifi dependency-version: 2026.10.18 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
Bump certifi from 2026.4.22 to 2026.10.18
Python 3.10 reached end-of-life in October 2026. Supported versions are now 3.11 through 3.15. - Bump cachebox to >=6.1.2,<7 (first release with cp315 wheels) - numpy ~=2.5.4 on 3.12+, ~=2.4.6 on 3.11; pandas ~=3.1.1 everywhere - Allow flit_core <5 as build backend - Upgrade dev/test/docs/static dependencies (polars 2.1, dateutil 4.0, Sphinx 9.0, pytest 9.2, coverage 7.17, pydantic 2.14, etc.) - Drop tomli dev dependency; always use stdlib tomllib - Remove pre-3.11 enum hash branch from tests - Update CI matrix and nox sessions to 3.11-3.15, run lint/coverage on 3.15
Add Python 3.15 support and drop Python 3.10
Replace hardcoded venv activation commands with guidance for detecting the contributor's active environment (VIRTUAL_ENV, direnv, .venv, uv). Remove stray references from another project, and gitignore CLAUDE.local.md for personal, machine-specific instructions.
Make CLAUDE.md setup-agnostic
- scripts/pr_sandbox/sandbox-pr.sh: fetch a PR without checking it out, show changed/risky files with control characters stripped, then run only its deepdiff/ and tests/ in the sandbox (deps and pytest config from the trusted checkout). - scripts/pr_sandbox/run-sandboxed.sh: bubblewrap sandbox (no network, read-only system and venv, throwaway $HOME with canary credentials and canary env vars) under strace, plus a PEP 578 audit hook. - scripts/pr_sandbox/analyze.py: turns strace/audit logs and a $HOME before/after diff into ranked findings; exits 2 on suspicious behaviour. A clean run of the current suite yields no MEDIUM+ findings. - CI: pr-sandbox-monitor runs the same on every PR; pr-risk-label (pull_request_target, no PR checkout) labels PRs touching build config, conftest, pickles, CI, agent config or the sandbox tooling. - CLAUDE.md: treat PR content as untrusted data when reviewing.
The work dir from mktemp is 0700, so chgrp on report/ alone is not enough for another user to read it. When the group exists and the user is in it, open up the work dir (traverse/list) plus report/ and audit/; src/ and the fake home stay private.
…r $HOME With a uv-managed Python under the user's home, CPython's startup search (~/lib/python315.zip etc.) was reported as MEDIUM home-read. Ignore such probes only under directories that contain the interpreter, so reads like ~/.local/lib/python3.15 are still reported.
…tes it The PR that introduces the monitor has no scripts/pr_sandbox on its base commit, so the job failed with 'No such file'. Use the PR's copy in that case, with a warning that the verdict is not trustworthy.
- make pr-sandbox PR=N: sandbox-pr.sh with a per-PR work dir under /tmp. - make pr-review PR=N: start the user's zsh claude command in plan mode with review-settings.json (auto/bypass disabled, risky commands ask, PreToolUse guard that blocks tool use in auto/bypass mode) and a review prompt pointing at the latest sandbox report. - make pr-clean: delete fetched PR refs and sandbox work dirs.
Plan mode prompted for every read of the report in /tmp. Use dontAsk with the sandbox work dir added via --add-dir: reads, read-only commands and gh pr view/diff/checks run without prompts, anything else is refused automatically. Deny code execution, network, edits and PR-mutating gh commands outright. Tell the reviewer to rely on analyze.py's findings instead of re-deriving them from strace.log.
Sandboxed, monitored test runs for untrusted PRs
DeepDiff(t1, t2, iterable_match_keys={path: key_spec}) pairs the items
of the selected lists by key instead of by position. Paths use the
exclude_paths glob syntax; a key spec is a key name, a tuple of key
names, or a callable. Matching runs inside _get_matching_pairs in
O(n + m), so results keep real list indexes and Delta round-trips.
- Duplicate keys pair by occurrence; items without a key pair in order.
- 1 and 1.0 are the same key; booleans and strings never match numbers.
- Records with different keys at the same index stay added + removed
instead of being merged into values_changed.
- With ignore_order, keyed lists are still paired by key, without
reporting moves.
- Lists inside a moved record skip difflib, and Delta no longer swaps
paths for items of opcode-diffed lists, so mixed diffs round-trip.
- Subtree multiprocessing falls back to serial, since workers can't
see absolute paths.
Also fixes iterable_compare_func dropping an added item whose content
equals an already matched item: matched t2 items are now tracked by
index, not content hash.
Closes #664
Closes #665
new uvlock
… an --add-dir value
…trip Fix Delta JSON round-trip crash when orjson is not installed. Thanks.
…ry-number-to-string test: handle negative imaginary parts in number_to_string
…imedelta datetime_normalize now truncates only datetime.datetime and datetime.time objects. It used to try every type except a plain date, so truncate_datetime raised AttributeError for timedelta in DeepDiff and for np.datetime64 in DeepHash. Neither type has a .replace() that takes time fields. Behaviour change: truncate_datetime no longer touches timedelta or np.datetime64 values, which are compared exactly. This matches existing behaviour elsewhere: DeepHash already hashed timedelta untruncated, and DeepDiff never truncated np.datetime64. Adds regression tests for timedelta (DeepDiff) and np.datetime64 (DeepHash).
truncate_datetime is intended to apply only to datetime and time objects. The previous np.datetime64 test used date-only values, where truncation is a no-op, and compared DeepHash objects, which always differ for different keys. Use values with a time component that differ only below the truncation unit and compare per-object hashes. Add tests for sub-second timedelta differences and for combining truncate_datetime with ignore_order=True.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #669 +/- ##
==========================================
+ Coverage 95.10% 95.21% +0.11%
==========================================
Files 17 19 +2
Lines 4900 5055 +155
==========================================
+ Hits 4660 4813 +153
- Misses 240 242 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release 9.2.0: merges
devintomaster.New features
iterable_match_keys: match list items by key per path, e.g.{"root['orders']": "order_id", "root['orders'][*]['lines']": ("sku", "warehouse")}. Paths use theexclude_pathsglob syntax; a key spec is a key name, a tuple of key names, or a callable. Matching is O(n + m), inserted/removed/reordered records are reported per record at real list indexes, andDeltaround-trips (Declarative key-based matching of list items per path (iterable_match_keys) #664, Add iterable_match_keys for key-based list matching per path (#664), fix #665 #666).1and1.0are the same key; booleans and strings never match numbers.ignore_order, keyed lists are still paired by key, without reporting moves.iterable_match_keysis used.docs/iterable_match_keys.rst.Python support
cachebox>=6.1.2,<7(first release with cp315 wheels); numpy~=2.5.4on 3.12+,~=2.4.6on 3.11; pandas~=3.1.1.flit_core<5.tomlidependency; stdlibtomllibis always used.Bug fixes
iterable_compare_funcdropping an added item whose content equals an already matched item, e.g.[{"id": 1}]vs[{"id": 1}, {"id": 1}]returned{}(iterable_compare_func: unmatched t2 item is dropped when its content equals a matched item #665, Add iterable_match_keys for key-based list matching per path (#664), fix #665 #666).DeepDiff([2], [2.0])now reports theint→floatchange (Type is not checked within groups #605, Fix missing type changes for equal-comparing list items (#605) #607), thanks to Sanjays2402.truncate_datetimecrashing on non-truncatable types. It now applies only todatetime.datetimeanddatetime.time;datetime.date,timedeltaandnp.datetime64values are compared exactly instead of raisingAttributeError(fix: skip time truncation for date objects in truncate_datetime #597, Skip truncate_datetime for non-truncatable types #617), thanks to SAY-5 and Sanjays2402.number_to_stringproducing an invalid string such as1.0+-1.0jfor complex numbers with a negative imaginary part, which crashed e.g.DeepHash(1-1j, significant_digits=3)(Common ValueError raised when formatting complex numbers #551, Handle negative imaginary parts in number_to_string (#551) #598, test: handle negative imaginary parts in number_to_string #616), thanks to koriyoshi2041 and Sanjays2402.TypeErrorwhen orjson is not installed, for list diffs that use iterable opcodes (Fix Delta JSON round-trip crash when orjson is not installed #613), thanks to chuenchen309._dict_from_slotsdropping a parent-declared mangled__slots__attribute for a subclass instance (Issue with subclasses, slots and mangled attributes #506, Fix mangled __slots__ attribute lost for subclass instances (#506) #609), thanks to uttam12331.deepcommand now exits with an actionable message (pip install "deepdiff[cli]") instead of aModuleNotFoundErrortraceback when thecliextra is not installed (cli - Missing dependency 'click' in default installation #594, fix(cli): give actionable error when 'deep' runs without cli extra (#594) #608), thanks to uttam12331.Dependencies
uv.lock(new uvlock #667).Tooling and docs
bump2version(broken on Python 3.15) tobump-my-version.scripts/pr_sandbox/), withmake pr-sandbox/make pr-reviewtargets (Sandboxed, monitored test runs for untrusted PRs #663).CLAUDE.mdsetup-agnostic instead of hardcoding a venv path (Make CLAUDE.md setup-agnostic #662).__slots__fix (Issue with subclasses, slots and mangled attributes #506) was moved from the v9-1-0 changelog section to v9-2-0, since it was merged after 9.1.0 was released.