Debian Codegraph @

CLAUDE.md

raw
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 4. **Using `pip` instead of `uv pip`**: This project uses `uv` for package management. Always use `uv pip` instead of `pip`.
66
67
68 ### Slow quality checks only to run before creating a build
69 ```bash
70 # Linting (max line length: 120)
71 nox -s flake8
72
73 # Type checking
74 nox -s mypy
75
76 # Run all quality checks
77 nox
78 ```
79
80
81 ## Architecture
82
83 ### Core Structure
84 - **deepdiff/diff.py**: Main DeepDiff implementation (most complex component)
85 - **deepdiff/deephash.py**: DeepHash functionality
86 - **deepdiff/base.py**: Shared base classes and functionality
87 - **deepdiff/model.py**: Core data structures and result objects
88 - **deepdiff/helper.py**: Utility functions and type definitions
89 - **deepdiff/delta.py**: Delta objects for applying changes
90
91 ### Key Patterns
92 - **Inheritance**: `Base` class provides common functionality with mixins
93 - **Result Objects**: Different result formats (`ResultDict`, `TreeResult`, `TextResult`)
94 - **Path Navigation**: Consistent path notation for nested object access
95 - **Performance**: LRU caching and numpy array optimization
96
97 ### Testing
98 - Located in `/tests/` directory
99 - Organized by functionality (e.g., `test_diff_text.py`, `test_hash.py`)
100 - Aims for ~100% test coverage
101 - Uses pytest with comprehensive fixtures
102
103 ## Development Notes
104
105 - **Python Support**: 3.10+ and PyPy3
106 - **Main Branch**: `master` (PRs typically go to `dev` branch)
107 - **Build System**: Modern `pyproject.toml` with `flit_core`
108 - **Dependencies**: Core dependency is `orderly-set>=5.4.1,<6`
109 - **CLI Tool**: Available as `deep` command after installation with `[cli]` extra