Skip to content

Commit 388a60e

Browse files
authored
Merge pull request #557 from seperman/dev
8.6.0
2 parents ecc823a + 0978fb8 commit 388a60e

37 files changed

+3732
-374
lines changed

.direnvrc.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function load_venv () {
2+
ACTUAL_VENV_PATH="$HOME/.venvs/$1"
3+
4+
if [ -d "$ACTUAL_VENV_PATH" ] && [ -f "$ACTUAL_VENV_PATH/bin/activate" ]; then
5+
echo "direnv: Activating $ACTUAL_VENV_PATH..."
6+
source "$ACTUAL_VENV_PATH/bin/activate"
7+
export UV_PROJECT_ENVIRONMENT="$ACTUAL_VENV_PATH"
8+
else
9+
echo "direnv: Virtual environment at $ACTUAL_VENV_PATH not found or is incomplete."
10+
fi
11+
}

.envrc.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
load_venv deep

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
env/
12+
.venv
1213
build/
1314
develop-eggs/
1415
dist/
@@ -71,3 +72,6 @@ temp*
7172
.env
7273

7374
pyrightconfig.json
75+
76+
# direnv file
77+
.envrc

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# DeepDiff Change log
22

3+
- v8-6-0
4+
- Added Colored View thanks to @mauvilsa
5+
- Added support for applying deltas to NamedTuple thanks to @paulsc
6+
- Fixed test_delta.py with Python 3.14 thanks to @Romain-Geissler-1A
7+
- Added python property serialization to json
8+
- Added ip address serialization
9+
- Switched to UV from pip
10+
- Added Claude.md
11+
- Added uuid hashing thanks to @akshat62
12+
- Added `ignore_uuid_types` flag to DeepDiff to avoid type reports when comparing UUID and string.
13+
- Added comprehensive type hints across the codebase (multiple commits for better type safety)
14+
- Added support for memoryview serialization
15+
- Added support for bytes serialization (non-UTF8 compatible)
16+
- Fixed bug where group_by with numbers would leak type info into group path reports
17+
- Fixed bug in `_get_clean_to_keys_mapping without` explicit significant digits
18+
- Added support for python dict key serialization
19+
- Enhanced support for IP address serialization with safe module imports
20+
- Added development tooling improvements (pyright config, .envrc example)
21+
- Updated documentation and development instructions
22+
323
- v8-5-0
424
- Updating deprecated pydantic calls
525
- Switching to pyproject.toml

CLAUDE.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
DeepDiff is a Python library for deep comparison, searching, and hashing of Python objects. It provides:
8+
- **DeepDiff**: Deep difference detection between objects
9+
- **DeepSearch**: Search for objects within other objects
10+
- **DeepHash**: Content-based hashing for any object
11+
- **Delta**: Git-like diff objects that can be applied to other objects
12+
- **CLI**: Command-line interface via `deep` command
13+
14+
## Development Commands
15+
16+
### Setup
17+
```bash
18+
# Install with all development dependencies
19+
uv pip install -e ".[cli,coverage,dev,docs,static,test]"
20+
# OR using uv (recommended)
21+
uv sync --all-extras
22+
```
23+
24+
**Virtual Environment**: Activate with `source ~/.venvs/deep/bin/activate` before running tests or Python commands
25+
26+
27+
### Testing
28+
```bash
29+
# Run tests with coverage
30+
source ~/.venvs/deep/bin/activate && pytest --cov=deepdiff --cov-report term-missing
31+
32+
# Run tests including slow ones
33+
source ~/.venvs/deep/bin/activate && pytest --cov=deepdiff --runslow
34+
35+
# Run single test file
36+
source ~/.venvs/deep/bin/activate && pytest tests/test_diff_text.py
37+
38+
# Run tests across multiple Python versions. No need to use this unless getting ready for creating a new build
39+
source ~/.venvs/deep/bin/activate && nox -s pytest
40+
```
41+
42+
### **Type Checking with Pyright:**
43+
Always use this pattern for type checking:
44+
```bash
45+
source ~/.venvs/deep/bin/activate && pyright {file_path}
46+
```
47+
48+
Examples:
49+
- `source ~/.venvs/deep/bin/activate && pyright deepdiff/diff.py` - Type check specific file
50+
- `source ~/.venvs/deep/bin/activate && pyright deepdiff/` - Type check entire module
51+
- `source ~/.venvs/deep/bin/activate && pyright .` - Type check entire repo
52+
53+
54+
### Common Pitfalls to Avoid
55+
56+
1. **Forgetting Virtual Environment**: ALWAYS activate venv before ANY Python command:
57+
```bash
58+
source ~/.venvs/deep/bin/activate
59+
```
60+
2. **Running pytest without venv**: This will cause import errors. Always use:
61+
```bash
62+
source ~/.venvs/deep/bin/activate && pytest
63+
```
64+
3. **Running module commands without venv**: Commands like `capi run`, `cettings shell`, etc. all require venv to be activated first
65+
66+
67+
### Slow quality checks only to run before creating a build
68+
```bash
69+
# Linting (max line length: 120)
70+
nox -s flake8
71+
72+
# Type checking
73+
nox -s mypy
74+
75+
# Run all quality checks
76+
nox
77+
```
78+
79+
80+
## Architecture
81+
82+
### Core Structure
83+
- **deepdiff/diff.py**: Main DeepDiff implementation (most complex component)
84+
- **deepdiff/deephash.py**: DeepHash functionality
85+
- **deepdiff/base.py**: Shared base classes and functionality
86+
- **deepdiff/model.py**: Core data structures and result objects
87+
- **deepdiff/helper.py**: Utility functions and type definitions
88+
- **deepdiff/delta.py**: Delta objects for applying changes
89+
90+
### Key Patterns
91+
- **Inheritance**: `Base` class provides common functionality with mixins
92+
- **Result Objects**: Different result formats (`ResultDict`, `TreeResult`, `TextResult`)
93+
- **Path Navigation**: Consistent path notation for nested object access
94+
- **Performance**: LRU caching and numpy array optimization
95+
96+
### Testing
97+
- Located in `/tests/` directory
98+
- Organized by functionality (e.g., `test_diff_text.py`, `test_hash.py`)
99+
- Aims for ~100% test coverage
100+
- Uses pytest with comprehensive fixtures
101+
102+
## Development Notes
103+
104+
- **Python Support**: 3.9+ and PyPy3
105+
- **Main Branch**: `master` (PRs typically go to `dev` branch)
106+
- **Build System**: Modern `pyproject.toml` with `flit_core`
107+
- **Dependencies**: Core dependency is `orderly-set>=5.4.1,<6`
108+
- **CLI Tool**: Available as `deep` command after installation with `[cli]` extra

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include *.txt
77
include *.sh
88
include pytest.ini
99
include *.py
10+
exclude uv.lock
1011
recursive-include docs/ *.rst
1112
recursive-include docs/ *.png
1213
recursive-include tests *.csv

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@ Tested on Python 3.9+ and PyPy3.
2323

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

26+
DeepDiff 8-6-0
27+
28+
- Added Colored View thanks to @mauvilsa
29+
- Added support for applying deltas to NamedTuple thanks to @paulsc
30+
- Fixed test_delta.py with Python 3.14 thanks to @Romain-Geissler-1A
31+
- Added python property serialization to json
32+
- Added ip address serialization
33+
- Switched to UV from pip
34+
- Added Claude.md
35+
- Added uuid hashing thanks to @akshat62
36+
- Added `ignore_uuid_types` flag to DeepDiff to avoid type reports when comparing UUID and string.
37+
- Added comprehensive type hints across the codebase (multiple commits for better type safety)
38+
- Added support for memoryview serialization
39+
- Added support for bytes serialization (non-UTF8 compatible)
40+
- Fixed bug where group_by with numbers would leak type info into group path reports
41+
- Fixed bug in `_get_clean_to_keys_mapping without` explicit significant digits
42+
- Added support for python dict key serialization
43+
- Enhanced support for IP address serialization with safe module imports
44+
- Added development tooling improvements (pyright config, .envrc example)
45+
- Updated documentation and development instructions
46+
47+
2648
DeepDiff 8-5-0
2749

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

85107
: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:
86108

109+
# Local dev
110+
111+
1. Clone the repo
112+
2. Switch to the dev branch
113+
3. Create your own branch
114+
4. Install dependencies
115+
116+
- Method 1: Use [`uv`](https://github.com/astral-sh/uv) to install the dependencies: `uv sync --all-extras`.
117+
- Method 2: Use pip: `pip install -e ".[cli,coverage,dev,docs,static,test]"`
118+
5. Build `flit build`
119+
87120
# Contribute
88121

89122
1. Please make your PR against the dev branch

deepdiff/base.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import uuid
2+
from typing import List, Optional, Union, Tuple, Any, Type
13
from deepdiff.helper import strings, numbers, SetOrdered
24

35

@@ -9,7 +11,7 @@ class Base:
911
numbers = numbers
1012
strings = strings
1113

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

21-
def get_ignore_types_in_groups(self, ignore_type_in_groups,
22-
ignore_string_type_changes,
23-
ignore_numeric_type_changes,
24-
ignore_type_subclasses):
23+
def get_ignore_types_in_groups(self,
24+
ignore_type_in_groups: Optional[Union[List[Any], Tuple[Any, ...]]],
25+
ignore_string_type_changes: bool,
26+
ignore_numeric_type_changes: bool,
27+
ignore_type_subclasses: bool,
28+
ignore_uuid_types: bool = False) -> List[Union[SetOrdered, Tuple[Type[Any], ...]]]:
2529
if ignore_type_in_groups:
2630
if isinstance(ignore_type_in_groups[0], type):
2731
ignore_type_in_groups = [ignore_type_in_groups]
@@ -43,6 +47,12 @@ def get_ignore_types_in_groups(self, ignore_type_in_groups,
4347
if ignore_numeric_type_changes and self.numbers not in ignore_type_in_groups:
4448
ignore_type_in_groups.append(SetOrdered(self.numbers))
4549

50+
if ignore_uuid_types:
51+
# Create a group containing both UUID and str types
52+
uuid_str_group = SetOrdered([uuid.UUID, str])
53+
if uuid_str_group not in ignore_type_in_groups:
54+
ignore_type_in_groups.append(uuid_str_group)
55+
4656
if not ignore_type_subclasses:
4757
# is_instance method needs tuples. When we look for subclasses, we need them to be tuples
4858
ignore_type_in_groups = list(map(tuple, ignore_type_in_groups))

0 commit comments

Comments
 (0)