Metadata-Version: 2.4
Name: bigbrother
Version: 0.1.5
Summary: A library for object observability
Project-URL: Repository, https://github.com/1kbgz/bigbrother
Project-URL: Homepage, https://github.com/1kbgz/bigbrother
Author-email: the bigbrother authors <dev@1kbgz.com>
License: Apache-2.0
License-File: LICENSE
Keywords: observer,observer-pattern
Classifier: Development Status :: 3 - Alpha
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
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.10
Requires-Dist: pydantic<3,>=2
Provides-Extra: develop
Requires-Dist: build; extra == 'develop'
Requires-Dist: bump-my-version; extra == 'develop'
Requires-Dist: check-dist; extra == 'develop'
Requires-Dist: codespell; extra == 'develop'
Requires-Dist: hatchling; extra == 'develop'
Requires-Dist: mdformat; extra == 'develop'
Requires-Dist: mdformat-tables>=1; extra == 'develop'
Requires-Dist: pytest; extra == 'develop'
Requires-Dist: pytest-cov; extra == 'develop'
Requires-Dist: ruff; extra == 'develop'
Requires-Dist: twine; extra == 'develop'
Requires-Dist: ty; extra == 'develop'
Requires-Dist: uv; extra == 'develop'
Requires-Dist: wheel; extra == 'develop'
Description-Content-Type: text/markdown

# bigbrother

Mutation callbacks for Python objects.

[![Build Status](https://github.com/1kbgz/bigbrother/actions/workflows/build.yaml/badge.svg?branch=main&event=push)](https://github.com/1kbgz/bigbrother/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/1kbgz/bigbrother/branch/main/graph/badge.svg)](https://codecov.io/gh/1kbgz/bigbrother)
[![License](https://img.shields.io/github/license/1kbgz/bigbrother)](https://github.com/1kbgz/bigbrother)
[![PyPI](https://img.shields.io/pypi/v/bigbrother.svg)](https://pypi.python.org/pypi/bigbrother)

`bigbrother` watches mutable Python objects and calls your callback when they
change. It is useful when another layer needs to mark state dirty, schedule a
refresh, or react to model changes without replacing every mutation call.

## Install

```bash
pip install bigbrother
```

## Example

```python
from bigbrother import watch

changes = []


def track_change(obj, method, ref, call_args, call_kwargs):
    changes.append((method, call_args, call_kwargs))


state = watch({"items": []}, track_change, deepstate=True)
state["items"].append("alpha")

assert changes[-1] == ("append", ("alpha",), {})
```

Keep the object returned by `watch()`. Built-in containers are observed by
returning watched container instances.

## Supported Objects

`bigbrother` supports:

- `list`, `dict`, and `set`
- `pydantic.BaseModel`
- plain Python objects and dataclasses with a `__dict__`

Objects without a `__dict__`, such as slot-only classes, are returned unchanged.
Callbacks fire before the underlying mutation completes.

## Documentation

- [API reference](https://1kbgz.github.io/bigbrother/docs/src/api.html)

## Development

```bash
make develop
python -m pytest bigbrother/tests -q
```

## License

`bigbrother` is licensed under Apache-2.0.

> [!NOTE]
> This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base).
