Skip to main content

pydatatracker

CI codecov PyPI version Python 3.12+

Utilities for building Python applications that require detailed state tracking. The package exposes tracked dictionary/list/attribute containers plus change-log helpers that make it easy to monitor modifications made while composing complex data payloads.

Why this project?

  • State awareness – record every mutation to your domain objects
  • Composable types – nest tracked containers or regular Python types
  • Observer-friendly – emit structured change logs for audit pipelines
  • Lightweight by default – snapshots, stack capture and actors are opt-in; declare _tracking_fields on a TrackedAttr subclass to skip creation-time log entries

Installation

pip install pydatatracker

Quick Start

from pydatatracker import ChangeCollector, TrackedDict, tracking_actor

payload = TrackedDict()
collector = ChangeCollector()
payload.tracking_add_observer(collector)

with tracking_actor("importer"):
    payload["status"] = "ready"

print(payload.last_change().actor)  # importer
print(collector.as_list()[-1].to_dict())

See the Usage Guide for history inspection, observers and exporters, and the Debugging & Observability Cookbook for snapshot and stack capture.

Documentation

📚 Full documentation is available in the docs/ directory

Build and view locally:

doit docs_serve  # Opens at http://127.0.0.1:8000

Key documentation files:

Development Setup

Prerequisites

  • Python 3.12+
  • uv - Fast Python package installer
  • direnv - Automatic environment variable loading (optional but recommended)

Quick Start

# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone repository
git clone https://github.com/endavis/pydatatracker.git
cd pydatatracker

# Create virtual environment and install dependencies
uv sync --all-extras --dev

# Install pre-commit hooks
doit pre_commit_install

# Optional: Install direnv for automatic environment management
# macOS:
brew install direnv

# Linux (using doit helper):
doit install_direnv

# Hook direnv into your shell (one-time setup)
# Bash:
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
source ~/.bashrc

# Zsh:
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
source ~/.zshrc

# Allow direnv to load .envrc
direnv allow

# Optional: Create .envrc.local for personal overrides
cp .envrc.local.example .envrc.local

The development tools, doit included, live in the dev and security extras, and a plain uv sync uninstalls them. Sync again later with doit install_dev, which runs the same command.

Versioning & Releases

This project uses automated versioning and releases powered by commitizen and hatch-vcs.

  • Single Source of Truth: The Git tag is the definitive version. pyproject.toml and _version.py are generated at build time from tags (no manual edits).
  • Versioning Scheme:
    • Production: Standard SemVer (e.g., v1.0.0).
    • Pre-release: PEP 440, as commitizen writes it (e.g., v1.0.1a0, v1.0.1b0, v1.0.1rc0).

Creating a Release

A release goes through a pull request. Run both steps from main.

1. Open the release PR:

doit release                     # Production release (PyPI)
doit release --prerelease=alpha  # Pre-release (TestPyPI): alpha, beta or rc

This automated task will:

  1. Calculate the next version based on conventional commits.
  2. Create a release/v<version> branch.
  3. Update CHANGELOG.md on it, merging any pre-release entries (commitizen --merge-prerelease).
  4. Push the branch and open a PR titled release: v<version>.

2. After the PR merges, tag the release:

doit release_tag

This tags main with v<version> and pushes the tag:

  • A production tag (e.g., v1.0.0) triggers the release workflow, which publishes to TestPyPI and then PyPI.
  • A pre-release tag (e.g., v1.0.1a0) triggers the testpypi workflow.

Environment Variables

This project uses direnv for automatic environment management. After setup:

  • .envrc (committed) contains project defaults and is loaded automatically
  • .envrc.local (git-ignored) is for personal overrides and credentials
  • Environment variables are set automatically when you enter the project directory
  • Virtual environment is activated automatically

Manual Setup (without direnv)

If you prefer not to use direnv:

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Set environment variables manually
# uv keeps its default cache, shared by every checkout and project

# Install dependencies
uv sync --all-extras --dev

Available Tasks

View all available tasks:

doit list

Quick Commands

# Testing
doit test          # Run tests (parallel execution with pytest-xdist)
doit coverage      # Run tests with coverage report

# Code Quality
doit format        # Format code with ruff
doit lint          # Run linting
doit type_check    # Run type checking with mypy
doit check         # Run ALL checks (format, lint, type check, security, audit, spell, test)

# Security
doit security      # Run security scan with bandit
doit audit         # Run dependency vulnerability audit
doit spell_check   # Check for typos with codespell
doit licenses      # Check licenses of dependencies

# Code Formatting
doit fmt_pyproject # Format pyproject.toml with pyproject-fmt

# Version Management (Commitizen)
doit commit        # Interactive commit with conventional format
doit release       # Open a release PR (--prerelease=alpha|beta|rc for TestPyPI)
doit release_tag   # Tag main after the release PR merges

# Documentation
doit docs_serve    # Serve docs locally with live reload
doit docs_build    # Build documentation site
doit docs_deploy   # Deploy docs to GitHub Pages

# Maintenance
doit cleanup       # Clean build artifacts and caches
doit update_deps   # Update dependencies and run tests

See the Usage Guide for comprehensive documentation of all development workflows.

Running Tests

# Run all tests (parallel execution - fast!)
doit test

# Run with coverage
doit coverage

# View coverage report
open tmp/htmlcov/index.html

# Advanced: Run specific test directly
uv run pytest tests/test_example.py::test_version -v

Code Quality

This project includes comprehensive tooling:

Core Tools

  • uv - Fast Python package installer and dependency manager
  • ruff - Extremely fast Python linter and formatter
  • mypy - Static type checker with strict mode
  • pytest - Testing framework with parallel execution (pytest-xdist)

Quality & Security

  • bandit - Security vulnerability scanner
  • codespell - Spell checker for code and documentation
  • pip-audit - Dependency vulnerability auditor
  • pip-licenses - License compliance checker
  • pre-commit - Git hooks for automated quality checks
  • pyproject-fmt - Keep pyproject.toml formatted and organized
  • commitizen - Enforce conventional commit message standards

Documentation

  • MkDocs - Documentation site generator
  • mkdocs-material - Material Design theme for MkDocs

Run all quality checks:

doit check

Pre-commit Hooks

Install hooks to run checks automatically before each commit:

doit pre_commit_install

Hooks include:

  • Code formatting (ruff)
  • Type checking (mypy)
  • Security scanning (bandit)
  • Spell checking (codespell)
  • YAML/TOML validation
  • Trailing whitespace removal
  • Private key detection

AI Agent Support

This project supports Claude Code, GitHub Copilot CLI, Codex CLI, and Antigravity CLI (agy). All four agents ship a complete cross-agent review command surface for self-action and cross-agent delegation, with slash names that differ by host: Claude uses colon separators (/claude:review, /claude:adversarial-review); Copilot and Codex use hyphen separators (/copilot-review, $codex-adversarial-review) because their command surface is skills and skill names cannot contain colons; Antigravity activates skills by description: match with no prefix. The shared workflow is: say "implement issue N" → review the PR → doit pr_merge --auto-close.

Requirements

Important: GitHub CLI (gh) is required for AI-assisted workflows.

Many doit tasks use gh for issue creation, PR management, and repository operations. Install and authenticate before using AI agents:

# Install (macOS)
brew install gh

# Install (Linux) - see https://github.com/cli/cli/blob/trunk/docs/install_linux.md

# Authenticate
gh auth login

Features

  • AGENTS.md - Instructions and protocols for AI agents
  • Dangerous command blocking - Hooks prevent destructive operations (force push to main, branch deletion, etc.)
  • Workflow automation - doit issue and doit pr for GitHub operations

See AI Agent Setup and AI Command Blocking for details.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and checks (doit check)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

See CHANGELOG.md for release history.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Add acknowledgments here

Metadata

Release files for pydatatracker 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydatatracker 0.2.0
File Size Uploaded Provenance Actions
pydatatracker-0.2.0.tar.gz 1.2 MB With provenance Details for pydatatracker-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydatatracker 0.2.0
File Interpreter ABI Platform Actions
pydatatracker-0.2.0-py3-none-any.whl Python 3 none any Details for pydatatracker-0.2.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / pydatatracker-0.2.0.tar.gz

Download URL pydatatracker-0.2.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
efd6493a28680258b44a0fe2f83101ca87c6c58e84ae5196342aa9cb9bf6c09e
BLAKE2b-256 checksum
How to use checksums
7982db99c13a69d0b83b55d324da547461a581f9f4e997fff9359025ced7e615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / pydatatracker-0.2.0-py3-none-any.whl

Download URL pydatatracker-0.2.0-py3-none-any.whl
Size 51.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f71836b68388460c5e2ab30604e11081bb51034bec65f39530c0f1456994691c
BLAKE2b-256 checksum
How to use checksums
50b258e17be806d244aff465476b2accb75b915655da72132d024ed031b2bd0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for pydatatracker 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydatatracker-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page