--- id: warlock version: "2.1.0" license: Apache-2.0 license_treatment: permissive maintenance: aging --- # warlock — Python object model built on JSON schema and JSON patch. License: permissive · Maintenance: aging · Downloads: 372.3K/mo ## 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 above — 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 pip install warlock uv add warlock 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_current - Install friction: low - Maintenance: aging - Downloads: 372.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags json schema validation python, self-validating python objects, json patch tracking, model validation library, schema-based object creation, python object validation, json schema model factory, schema-validation, json-patch, data-modeling [View on SkillFed](https://skillfed.io/packages/warlock) · [View on PyPI](https://pypi.org/project/warlock/)