Metadata-Version: 2.4
Name: ocdiff
Version: 0.0.50
Classifier: Programming Language :: Python
Requires-Dist: maturin==1.7.4 ; extra == 'dev'
Requires-Dist: pytest==7.* ; extra == 'dev'
Requires-Dist: mypy==1.6.* ; extra == 'dev'
Requires-Dist: pip==24.2 ; extra == 'dev'
Requires-Dist: attrs==26.* ; extra == 'test'
Requires-Dist: django==6.* ; extra == 'test'
Requires-Dist: pydantic==2.13.4 ; extra == 'test'
Requires-Dist: pytest==7.* ; extra == 'test'
Requires-Dist: rich==15.* ; extra == 'test'
Provides-Extra: dev
Provides-Extra: test
License-File: LICENSE
Summary: difftastic Python wrapper
Keywords: diff
Author-email: Oliver Russell <ojhrussell@gmail.com>
Maintainer-email: Oliver Russell <ojhrussell@gmail.com>
Requires-Python: >=3.12
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: documentation, https://github.com/leontrolski/ocdiff
Project-URL: homepage, https://github.com/leontrolski/ocdiff
Project-URL: repository, https://github.com/leontrolski/ocdiff.git

# ocdiff

Fast and simple side-by-side diff library for Python - wraps [similar](https://crates.io/crates/similar), inspired by [icdiff](https://github.com/jeffkaufman/icdiff).

# Usage

```shell
pip install ocdiff
```

```python
ocdiff.html_diff(
    a: str,
    b: str,
    context_lines: int | None = None,
    max_total_width: int | None = None,
) -> str
```

```python
ocdiff.console_diff(
    a: str,
    b: str,
    context_lines: int | None = None,
    max_total_width: int | None = None,
) -> str
```

# Example Output

![Screenshot](screenshot-1.png)

# CLI usage

```shell
ocdiff a.txt b.txt
```

# `pytest` plugin

A pytest plugin is provided, it relies on the presence of [rich](https://github.com/Textualize/rich), usage is:

```shell
pytest ... -vv --ocdiff
```

On the assumption that you are following the convention `assert actual == expected`, there is also:

```shell
pytest ... --copy-left
```

For snapshot testing on the cheap.

To customize the repr for both of the above, override the global `ocdiff.pytest_plugin.PRETTY_REPR_CLS` with a subclass of `ocdiff.repr_helpers.PrettyRepr`:

<br>
<hr>
<br>

# Install/Develop

```shell
uv pip install -e '.[dev]'
maturin develop
```

# Make release

- Add pypi token and user = `__token__` to settings (do this once).
- Upversion `pyproject.toml`.

```shell
export VERSION=$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])'); git tag -a v$VERSION head -m v$VERSION && git push origin v$VERSION
```

