warlock
Python object model built on JSON schema and JSON patch.
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 warlockuv
uv add warlockpoetry
poetry add warlockInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
schemaValidates Python data structures (dicts, lists,…
permissive · top 1,000 on PyPI
pydantic-geojsonProvides Pydantic-based type-safe validation…
permissive · top 15,000 on PyPI
pykwalifyValidates YAML and JSON data against schemas…
permissive · top 5,000 on PyPI
gensonGenSON generates JSON Schema documents from…
permissive · top 5,000 on PyPI
drf-jsonschema-serializerConverts Django REST Framework serializers to…
permissive · top 15,000 on PyPI
jsonschema-pydanticConverts JSON Schema definitions into Pydantic…
unclear · top 15,000 on PyPI
jsonpointerResolves JSON Pointers according to RFC 6901,…
permissive · top 1,000 on PyPI
django-mock-queriesMocks Django QuerySet operations in memory for…
permissive · top 15,000 on PyPI
zcborzcbor validates and converts YAML/JSON/CBOR…
permissive · top 15,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI