Skip to content

8.6.0 #557

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

Merged
merged 43 commits into from
Aug 8, 2025
Merged

8.6.0 #557

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b25f726
Colored view
mauvilsa May 10, 2025
eca5dfe
Colored compact view
mauvilsa May 19, 2025
77fa8d3
Fix CLI
mauvilsa May 20, 2025
18a0334
Fix bool evaluation
mauvilsa May 20, 2025
82f890c
Fixes and more tests
mauvilsa May 22, 2025
50617f9
adding uv
seperman May 27, 2025
bce6343
Fix array bugs
mauvilsa May 28, 2025
5a7ded3
adding support to ip addresses
seperman Jun 7, 2025
662f9ba
adding ip address modules safe for import
seperman Jun 7, 2025
c7e581f
adding support to ip addresses
seperman Jun 7, 2025
d5f23df
Adding support for applying deltas to NamedTuple
paulsc Jun 20, 2025
10cb342
Handle one more case where NamedTuple has a frozenset.
paulsc Jun 23, 2025
f40fa0e
Fix test_delta.py with Python 3.14.
Romain-Geissler-1A Jun 29, 2025
10baf2a
serializing properties
seperman Jul 2, 2025
07e7d0a
Merge pull request #556 from Romain-Geissler-1A/master
seperman Jul 2, 2025
1c30c5a
Merge pull request #549 from mauvilsa/colored-view
seperman Jul 2, 2025
4c02bf9
Merge pull request #554 from paulsc/namedtuple-add-delta
seperman Jul 2, 2025
8d1399b
adding Claude.md
seperman Jul 2, 2025
2b1a039
gh-535: UUID set comparison failure
akshat62 Jul 8, 2025
b9af75d
Adding test cases
akshat62 Jul 9, 2025
5c815c8
updating docs
seperman Jul 13, 2025
6b01e71
adding ignore_uuid_types flag
seperman Jul 13, 2025
66eb8f6
Merge branch 'gh-535/UUID-set-comparison-failure' of github.com:aksha…
seperman Jul 13, 2025
791bdfa
fixing the implementation for hashing uuid
seperman Jul 13, 2025
8121be3
supporing memoryview
seperman Jul 14, 2025
5e514c5
serializing memoryview
seperman Jul 14, 2025
687ea04
adding one more test case
seperman Jul 15, 2025
e4b59cf
adding a test case for delta and list of bytes
seperman Jul 21, 2025
f8397c7
fixes a bug when _get_clean_to_keys_mapping would be called without
seperman Jul 21, 2025
43acb92
fixing the case where group_by by a number would leak type info into the
seperman Jul 23, 2025
59fbd1d
deepdiff seralizing python dict keys
seperman Jul 31, 2025
c352332
adding support for serialization of bytes taht are not utf8 compatible
seperman Aug 7, 2025
cdd3afc
updating claude instructions
seperman Aug 8, 2025
be8c9f3
adding .envrc example
seperman Aug 8, 2025
3eb50b8
adding a pyright config example
seperman Aug 8, 2025
a1565c4
adding type hints to deephash
seperman Aug 8, 2025
9176359
adding type hints to the helper function
seperman Aug 8, 2025
f7b6510
Adding type hints to model.py
seperman Aug 8, 2025
b6c93ca
adding type hints
seperman Aug 8, 2025
33de087
adding type hints to search
seperman Aug 8, 2025
e16507c
fixing type hints
seperman Aug 8, 2025
d469a4c
making type hints compatible with old python
seperman Aug 8, 2025
0978fb8
adding docs for 8.6.0
seperman Aug 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .direnvrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function load_venv () {
ACTUAL_VENV_PATH="$HOME/.venvs/$1"

if [ -d "$ACTUAL_VENV_PATH" ] && [ -f "$ACTUAL_VENV_PATH/bin/activate" ]; then
echo "direnv: Activating $ACTUAL_VENV_PATH..."
source "$ACTUAL_VENV_PATH/bin/activate"
export UV_PROJECT_ENVIRONMENT="$ACTUAL_VENV_PATH"
else
echo "direnv: Virtual environment at $ACTUAL_VENV_PATH not found or is incomplete."
fi
}
1 change: 1 addition & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load_venv deep
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
.venv
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -71,3 +72,6 @@ temp*
.env

pyrightconfig.json

# direnv file
.envrc
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# DeepDiff Change log

- v8-6-0
- Added Colored View thanks to @mauvilsa
- Added support for applying deltas to NamedTuple thanks to @paulsc
- Fixed test_delta.py with Python 3.14 thanks to @Romain-Geissler-1A
- Added python property serialization to json
- Added ip address serialization
- Switched to UV from pip
- Added Claude.md
- Added uuid hashing thanks to @akshat62
- Added `ignore_uuid_types` flag to DeepDiff to avoid type reports when comparing UUID and string.
- Added comprehensive type hints across the codebase (multiple commits for better type safety)
- Added support for memoryview serialization
- Added support for bytes serialization (non-UTF8 compatible)
- Fixed bug where group_by with numbers would leak type info into group path reports
- Fixed bug in `_get_clean_to_keys_mapping without` explicit significant digits
- Added support for python dict key serialization
- Enhanced support for IP address serialization with safe module imports
- Added development tooling improvements (pyright config, .envrc example)
- Updated documentation and development instructions

- v8-5-0
- Updating deprecated pydantic calls
- Switching to pyproject.toml
Expand Down
108 changes: 108 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

DeepDiff is a Python library for deep comparison, searching, and hashing of Python objects. It provides:
- **DeepDiff**: Deep difference detection between objects
- **DeepSearch**: Search for objects within other objects
- **DeepHash**: Content-based hashing for any object
- **Delta**: Git-like diff objects that can be applied to other objects
- **CLI**: Command-line interface via `deep` command

## Development Commands

### Setup
```bash
# Install with all development dependencies
uv pip install -e ".[cli,coverage,dev,docs,static,test]"
# OR using uv (recommended)
uv sync --all-extras
```

**Virtual Environment**: Activate with `source ~/.venvs/deep/bin/activate` before running tests or Python commands


### Testing
```bash
# Run tests with coverage
source ~/.venvs/deep/bin/activate && pytest --cov=deepdiff --cov-report term-missing

# Run tests including slow ones
source ~/.venvs/deep/bin/activate && pytest --cov=deepdiff --runslow

# Run single test file
source ~/.venvs/deep/bin/activate && pytest tests/test_diff_text.py

# Run tests across multiple Python versions. No need to use this unless getting ready for creating a new build
source ~/.venvs/deep/bin/activate && nox -s pytest
```

### **Type Checking with Pyright:**
Always use this pattern for type checking:
```bash
source ~/.venvs/deep/bin/activate && pyright {file_path}
```

Examples:
- `source ~/.venvs/deep/bin/activate && pyright deepdiff/diff.py` - Type check specific file
- `source ~/.venvs/deep/bin/activate && pyright deepdiff/` - Type check entire module
- `source ~/.venvs/deep/bin/activate && pyright .` - Type check entire repo


### Common Pitfalls to Avoid

1. **Forgetting Virtual Environment**: ALWAYS activate venv before ANY Python command:
```bash
source ~/.venvs/deep/bin/activate
```
2. **Running pytest without venv**: This will cause import errors. Always use:
```bash
source ~/.venvs/deep/bin/activate && pytest
```
3. **Running module commands without venv**: Commands like `capi run`, `cettings shell`, etc. all require venv to be activated first


### Slow quality checks only to run before creating a build
```bash
# Linting (max line length: 120)
nox -s flake8

# Type checking
nox -s mypy

# Run all quality checks
nox
```


## Architecture

### Core Structure
- **deepdiff/diff.py**: Main DeepDiff implementation (most complex component)
- **deepdiff/deephash.py**: DeepHash functionality
- **deepdiff/base.py**: Shared base classes and functionality
- **deepdiff/model.py**: Core data structures and result objects
- **deepdiff/helper.py**: Utility functions and type definitions
- **deepdiff/delta.py**: Delta objects for applying changes

### Key Patterns
- **Inheritance**: `Base` class provides common functionality with mixins
- **Result Objects**: Different result formats (`ResultDict`, `TreeResult`, `TextResult`)
- **Path Navigation**: Consistent path notation for nested object access
- **Performance**: LRU caching and numpy array optimization

### Testing
- Located in `/tests/` directory
- Organized by functionality (e.g., `test_diff_text.py`, `test_hash.py`)
- Aims for ~100% test coverage
- Uses pytest with comprehensive fixtures

## Development Notes

- **Python Support**: 3.9+ and PyPy3
- **Main Branch**: `master` (PRs typically go to `dev` branch)
- **Build System**: Modern `pyproject.toml` with `flit_core`
- **Dependencies**: Core dependency is `orderly-set>=5.4.1,<6`
- **CLI Tool**: Available as `deep` command after installation with `[cli]` extra
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include *.txt
include *.sh
include pytest.ini
include *.py
exclude uv.lock
recursive-include docs/ *.rst
recursive-include docs/ *.png
recursive-include tests *.csv
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ Tested on Python 3.9+ and PyPy3.

Please check the [ChangeLog](CHANGELOG.md) file for the detailed information.

DeepDiff 8-6-0

- Added Colored View thanks to @mauvilsa
- Added support for applying deltas to NamedTuple thanks to @paulsc
- Fixed test_delta.py with Python 3.14 thanks to @Romain-Geissler-1A
- Added python property serialization to json
- Added ip address serialization
- Switched to UV from pip
- Added Claude.md
- Added uuid hashing thanks to @akshat62
- Added `ignore_uuid_types` flag to DeepDiff to avoid type reports when comparing UUID and string.
- Added comprehensive type hints across the codebase (multiple commits for better type safety)
- Added support for memoryview serialization
- Added support for bytes serialization (non-UTF8 compatible)
- Fixed bug where group_by with numbers would leak type info into group path reports
- Fixed bug in `_get_clean_to_keys_mapping without` explicit significant digits
- Added support for python dict key serialization
- Enhanced support for IP address serialization with safe module imports
- Added development tooling improvements (pyright config, .envrc example)
- Updated documentation and development instructions


DeepDiff 8-5-0

- Updating deprecated pydantic calls
Expand Down Expand Up @@ -84,6 +106,17 @@ Please take a look at the [CHANGELOG](CHANGELOG.md) file.

:mega: **Please fill out our [fast 5-question survey](https://forms.gle/E6qXexcgjoKnSzjB8)** so that we can learn how & why you use DeepDiff, and what improvements we should make. Thank you! :dancers:

# Local dev

1. Clone the repo
2. Switch to the dev branch
3. Create your own branch
4. Install dependencies

- Method 1: Use [`uv`](https://github.com/astral-sh/uv) to install the dependencies: `uv sync --all-extras`.
- Method 2: Use pip: `pip install -e ".[cli,coverage,dev,docs,static,test]"`
5. Build `flit build`

# Contribute

1. Please make your PR against the dev branch
Expand Down
20 changes: 15 additions & 5 deletions deepdiff/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import uuid
from typing import List, Optional, Union, Tuple, Any, Type
from deepdiff.helper import strings, numbers, SetOrdered


Expand All @@ -9,7 +11,7 @@ class Base:
numbers = numbers
strings = strings

def get_significant_digits(self, significant_digits, ignore_numeric_type_changes):
def get_significant_digits(self, significant_digits: Optional[int], ignore_numeric_type_changes: bool) -> Optional[int]:
if significant_digits is not None and significant_digits < 0:
raise ValueError(
"significant_digits must be None or a non-negative integer")
Expand All @@ -18,10 +20,12 @@ def get_significant_digits(self, significant_digits, ignore_numeric_type_changes
significant_digits = DEFAULT_SIGNIFICANT_DIGITS_WHEN_IGNORE_NUMERIC_TYPES
return significant_digits

def get_ignore_types_in_groups(self, ignore_type_in_groups,
ignore_string_type_changes,
ignore_numeric_type_changes,
ignore_type_subclasses):
def get_ignore_types_in_groups(self,
ignore_type_in_groups: Optional[Union[List[Any], Tuple[Any, ...]]],
ignore_string_type_changes: bool,
ignore_numeric_type_changes: bool,
ignore_type_subclasses: bool,
ignore_uuid_types: bool = False) -> List[Union[SetOrdered, Tuple[Type[Any], ...]]]:
if ignore_type_in_groups:
if isinstance(ignore_type_in_groups[0], type):
ignore_type_in_groups = [ignore_type_in_groups]
Expand All @@ -43,6 +47,12 @@ def get_ignore_types_in_groups(self, ignore_type_in_groups,
if ignore_numeric_type_changes and self.numbers not in ignore_type_in_groups:
ignore_type_in_groups.append(SetOrdered(self.numbers))

if ignore_uuid_types:
# Create a group containing both UUID and str types
uuid_str_group = SetOrdered([uuid.UUID, str])
if uuid_str_group not in ignore_type_in_groups:
ignore_type_in_groups.append(uuid_str_group)

if not ignore_type_subclasses:
# is_instance method needs tuples. When we look for subclasses, we need them to be tuples
ignore_type_in_groups = list(map(tuple, ignore_type_in_groups))
Expand Down
Loading