Skip to content

Commit cf882f8

Browse files
committed
refactor: modernize deep-diff project to 2026 standards
- Migrate setup.py to pyproject.toml (PEP 517/518) - Add comprehensive type hints to all functions - Update code style to PEP 8 with black formatting - Migrate tests from unittest to pytest (31 tests, 88% coverage) - Add GitHub Actions CI/CD workflows - Improve documentation with detailed README and CONTRIBUTING guide - Add proper LICENSE file - Expand .gitignore for modern Python development - Update project metadata and support Python 3.8-3.12 - Remove old test.py and README.MD files This modernization brings the 8-year-old project to current Python standards.
1 parent d8d9a15 commit cf882f8

14 files changed

Lines changed: 1331 additions & 260 deletions

File tree

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master, main, develop]
6+
pull_request:
7+
branches: [master, main, develop]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, macos-latest, windows-latest]
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e ".[dev]"
30+
31+
- name: Lint with ruff
32+
run: |
33+
ruff check deep_diff tests
34+
35+
- name: Format check with black
36+
run: |
37+
black --check deep_diff tests
38+
39+
- name: Type check with mypy
40+
run: |
41+
mypy deep_diff
42+
43+
- name: Test with pytest
44+
run: |
45+
pytest --cov=deep_diff --cov-report=xml --cov-report=term-missing
46+
47+
- name: Upload coverage to Codecov
48+
uses: codecov/codecov-action@v3
49+
with:
50+
files: ./coverage.xml
51+
fail_ci_if_error: false
52+
53+
build:
54+
runs-on: ubuntu-latest
55+
needs: test
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v4
61+
with:
62+
python-version: "3.11"
63+
64+
- name: Install build dependencies
65+
run: |
66+
python -m pip install --upgrade pip
67+
pip install build
68+
69+
- name: Build distribution
70+
run: |
71+
python -m build
72+
73+
- name: Check built artifacts
74+
run: |
75+
ls -la dist/
76+
tar -tzf dist/*.tar.gz | head -20

.github/workflows/quality.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
jobs:
10+
quality:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -e ".[dev]"
24+
25+
- name: Run Ruff formatter check
26+
run: ruff format --check deep_diff tests
27+
28+
- name: Run Ruff linter
29+
run: ruff check deep_diff tests
30+
31+
- name: Check with mypy
32+
run: mypy deep_diff --pretty

.gitignore

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
1-
__pycache__
2-
.vscode
3-
dist
4-
*.egg-info
5-
build
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
*.manifest
32+
*.spec
33+
34+
# Unit test / coverage reports
35+
htmlcov/
36+
.tox/
37+
.nox/
38+
.coverage
39+
.coverage.*
40+
.cache
41+
nosetests.xml
42+
coverage.xml
43+
*.cover
44+
*.py,cover
45+
.hypothesis/
46+
.pytest_cache/
47+
48+
# Virtual environments
49+
venv/
50+
ENV/
51+
env/
52+
.venv
53+
54+
# IDEs
55+
.vscode/
56+
.idea/
57+
*.swp
58+
*.swo
59+
*~
60+
.DS_Store
61+
62+
# mypy
63+
.mypy_cache/
64+
.dmypy.json
65+
dmypy.json
66+
67+
# Pyre type checker
68+
.pyre/
69+
70+
# ruff
71+
.ruff_cache/
72+
73+
# Misc
74+
*.log
75+
.env
76+
.env.local

CONTRIBUTING.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
"""
2+
CONTRIBUTING Guide for deep-diff
3+
================================
4+
5+
Thank you for considering contributing to deep-diff! This document provides
6+
guidelines and instructions for contributing to the project.
7+
8+
## Getting Started
9+
10+
1. **Fork the repository** on GitHub
11+
2. **Clone your fork** locally:
12+
```bash
13+
git clone https://github.com/YOUR_USERNAME/diff.git
14+
cd diff
15+
```
16+
3. **Create a virtual environment**:
17+
```bash
18+
python -m venv venv
19+
source venv/bin/activate # On Windows: venv\Scripts\activate
20+
```
21+
4. **Install development dependencies**:
22+
```bash
23+
pip install -e ".[dev]"
24+
```
25+
26+
## Development Workflow
27+
28+
### Making Changes
29+
30+
1. **Create a feature branch**:
31+
```bash
32+
git checkout -b feature/your-feature-name
33+
```
34+
2. **Make your changes** to the code
35+
3. **Write or update tests** for your changes
36+
4. **Run tests locally**:
37+
```bash
38+
pytest
39+
```
40+
5. **Format and lint your code**:
41+
```bash
42+
black deep_diff tests
43+
ruff check --fix deep_diff tests
44+
mypy deep_diff
45+
```
46+
47+
### Testing
48+
49+
- All new features should include tests
50+
- Tests should be added to `tests/test_deep_diff.py`
51+
- Aim for >90% code coverage
52+
- Run tests with coverage:
53+
```bash
54+
pytest --cov=deep_diff --cov-report=html
55+
```
56+
57+
### Code Style
58+
59+
- **Formatting**: Use `black` (line length: 100)
60+
- **Linting**: Use `ruff`
61+
- **Type hints**: Add type hints to all public functions
62+
- **Docstrings**: Use Google-style docstrings
63+
64+
### Commit Messages
65+
66+
- Use clear, descriptive commit messages
67+
- Start with a verb (Add, Fix, Update, etc.)
68+
- Reference issues when applicable: "Fix #123"
69+
- Example: "Add type hints to diff function"
70+
71+
### Pull Request Process
72+
73+
1. **Push to your fork**:
74+
```bash
75+
git push origin feature/your-feature-name
76+
```
77+
2. **Create a Pull Request** on GitHub
78+
3. **Write a clear PR description**:
79+
- What changes you made
80+
- Why you made them
81+
- Any related issues
82+
4. **Ensure CI passes** (tests, linting, type checking)
83+
5. **Request review** from maintainers
84+
85+
## Areas for Contribution
86+
87+
- 🐛 **Bug fixes**: Report and fix issues
88+
-**Features**: Suggest and implement new functionality
89+
- 📚 **Documentation**: Improve documentation and examples
90+
- 🧪 **Tests**: Add test cases for edge cases
91+
- 🚀 **Performance**: Optimize performance-critical code
92+
93+
## Reporting Issues
94+
95+
- Use GitHub Issues for bug reports
96+
- Include:
97+
- Clear description of the issue
98+
- Steps to reproduce
99+
- Expected vs actual behavior
100+
- Python version and OS
101+
- Minimal code example
102+
103+
## Questions?
104+
105+
- Open an issue for discussion
106+
- Check existing issues and PRs first
107+
- Be respectful and constructive
108+
109+
## Code of Conduct
110+
111+
- Be respectful to all contributors
112+
- Follow PEP 8 style guidelines
113+
- Test your changes thoroughly
114+
- Write clear, understandable code
115+
116+
## License
117+
118+
By contributing, you agree that your contributions will be licensed under
119+
the same BSD 3-Clause License as the project.
120+
121+
---
122+
123+
Thanks for contributing to deep-diff! 🎉
124+
"""

LICENSE

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
LICENSE - BSD 3-Clause License
3+
4+
Copyright (c) 2026, ider
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
1. Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
2. Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
3. Neither the name of the copyright holder nor the names of its
18+
contributors may be used to endorse or promote products derived from
19+
this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
"""

0 commit comments

Comments
 (0)