skillfed

warlock

Python object model built on JSON schema and JSON patch.

warlock v2.1.0 372.3K downloads/30d#7,163 on PyPI150
Permissive license Apache-2.0 AGING released

What it is and what it does

Warlock is a Python library that generates model classes from JSON schemas, binding validation logic directly to object instances. When you define a schema and use warlock.model_factory() to create a class, instances of that class automatically validate all attribute assignments against the schema constraints—rejecting invalid types, disallowing undeclared properties (if additionalProperties is false), and raising InvalidOperation exceptions on violations.

The library integrates jsonschema for validation and jsonpatch for change tracking. Every mutation to a validated object is recorded, and you can retrieve a JSON Patch document describing all changes since the object was created. This makes warlock useful for scenarios where you need runtime type safety, audit trails of object modifications, or serializable representations of state changes.

Use it for:

  • Build domain models with automatic type enforcement, catching invalid assignments at runtime instead of downstream
  • Track object mutations as JSON Patch documents for audit logs, change notifications, or state synchronization
  • Validate API request/response payloads by wrapping them in schema-backed models before processing
  • Generate model classes dynamically from external JSON schema definitions without hand-coding validators
  • Enforce data contracts in collaborative systems where multiple components share the same schema definition

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Warlock creates self-validating Python objects using JSON schema, automatically enforcing type and structure constraints on object attributes and tracking changes as JSON Patch documents.

Yes, if you need runtime validation and change tracking for Python objects. The package is stable, has no known vulnerabilities, and low install friction. The aging maintenance (441 days since last release) is a minor concern but not a blocker given the Production/Stable status and active repository. Install it for schema-driven model validation; avoid it if you prefer external validation frameworks or don't need JSON Patch tracking.

Install

warlock on PyPI

pip

pip install warlock

uv

uv add warlock

poetry

poetry add warlock

Installing warlock

Before you install

Low install friction with a pure-Python wheel and only two lightweight dependencies (jsonschema and jsonpatch). Maintenance is aging—last release was 441 days ago—but the repository is not archived and the package is marked Production/Stable.

License in practice

Licensed under Apache-2.0 (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

pip install warlock

import warlock

schema = {
    'name': 'Country',
    'properties': {
        'name': {'type': 'string'},
        'population': {'type': 'integer'},
    },
    'additionalProperties': False,
}

Country = warlock.model_factory(schema)
sweden = Country(name='Sweden', population=9453000)
sweden.patch  # '[{"path": "/population", "value": 9453000, "op": "add"}]'

Verify before relying

  • Whether the aging maintenance status (441 days since last release) affects compatibility with the latest Python minor versions despite classifier support for 3.9–3.13
  • Performance characteristics when validating large object graphs or high-frequency attribute updates

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 2 — jsonschema, jsonpatch
Maintenance aging — 441 days since the last release
Last repo commit
First released
Downloads 372,321/month — #7,163 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: warlock-2.1.0-py3-none-any.whl

Keywords: JSON schema, JSON patch, model validation

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python Modules

Tags

json schema validation pythonself-validating python objectsjson patch trackingmodel validation libraryschema-based object creationpython object validationjson schema model factory
schema-validationjson-patchdata-modeling

More Python Modules packages