Metadata-Version: 2.4
Name: python-deepcompare
Version: 2.2.0
Summary: A library for deep comparison of data structures consisting of dict, list and tuple.
Author-email: Anexia <opensource@anexia-it.com>
License: The MIT License (MIT)
        
        Copyright (c) 2021-2026 Anexia
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/anexia/python-deepcompare
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: coverage>=7.13.2; extra == "test"
Requires-Dist: pytest>=8; extra == "test"
Provides-Extra: dev
Requires-Dist: pre-commit<4.6,>=4.5; extra == "dev"
Provides-Extra: build
Requires-Dist: build>=1.4.0; extra == "build"
Requires-Dist: twine>=6.2.0; extra == "build"
Requires-Dist: wheel>=0.46.3; extra == "build"
Dynamic: license-file

deepcompare
===========

[![PyPI](https://badge.fury.io/py/deepcompare.svg)](https://pypi.org/project/deepcompare/)
[![Test Status](https://github.com/anexia/python-deepcompare/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/python-deepcompare/actions/workflows/test.yml)
[![Codecov](https://codecov.io/gh/anexia/python-deepcompare/branch/main/graph/badge.svg)](https://codecov.io/gh/anexia/python-deepcompare)

`deepcompare` is a library to deeply compare data structures with each other. It can check if two data
structures contain the same data, or if a data structure is a subset of another data structure. The library
supports `Sequence` (e.g. `list` or `tuple`) and `Mapping` (e.g. `dict`) types for the deep comparison.

# Installation

With a [correctly configured](https://pipenv.pypa.io/en/latest/basics/#basic-usage-of-pipenv) `pipenv` toolchain:

```sh
pipenv install python-deepcompare
```

You may also use classic `pip` to install the package:

```sh
pip install python-deepcompare
```

# Getting started

## How it works
 - As a default, the comparison treats all `Sequence` and all `Mapping` types the same (e.g. `(1, 2, 3)` is equal to
   `[1, 2, 3]`). To enable strict type checks, use the `strict` keyword argument.
 - The `partial_compare` method checks if the data structure given as the second parameter is a subset of the data
   structure given as the first parameter.
   - For `Mapping` types this means, that all keys of the second data structure are also keys on the first data
     structure, and the values of the keys are also equal (e.g. `{'a': 1, 'b': 2}` is a subset
     of `{'a': 1, 'b': 2, 'c': 3}`, but `{'a': 1, 'b': 2, 'd': 4}` is not).
   - For `Sequence` types this means, that all values of the second data structure are also values of the first data
     structure, and the values are in the same order (e.g. `[1, 3, 5]` is a subset
     of `[1, 2, 3, 4, 5]`, but `[1, 5, 3]` is not).

## Usage

```python
import deepcompare

# test if two data structures are equal, but the types to not need to match exactly
deepcompare.compare(
    {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}},
    {'key1': [1, 2, 3], 'key2': {'key3': (4, 5, 6)}},
)  # returns: True

# test if two data structures are equal, and make sure the types match exactly
deepcompare.compare(
    {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}},
    {'key1': [1, 2, 3], 'key2': {'key3': (4, 5, 6)}},
    strict=True,
)  # returns: False

# test if the second data structure is contained within the first, but
# the types to not need to match exactly
deepcompare.partial_compare(
    {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True},
    {'key1': [1, 2], 'key2': {'key3': (4, 6)}},
)  # returns: True

# test if the second data structure is contained within the first, and
# make sure the types match exactly
deepcompare.partial_compare(
    {'key1': (1, 2, 3), 'key2': {'key3': [4, 5, 6]}, 'key4': True},
    {'key1': [1, 2], 'key2': {'key3': (4, 6)}},
    strict=True,
)  # returns: False
```

# List of developers

* Andreas Stocker <AStocker@anexia-it.com>, Lead Developer
