Skip to main content

Type-based validation for dict-based configs.

Project description

Apathetic Python Schema 🧩

CI License: MIT-a-NOAI Discord

📘 Roadmap · 📝 Release Notes

Lightweight validation for dict-based configs.
Types can be schema too.

Apathetic Python Schema validates dict-based data structures (configs, usually from JSONC/JSON/TOML) using Python TypedDicts used for mypy/pyright. No need for separate schema definitions — your type annotations are your schema.

[!NOTE] Heads up: the AI cooked dinner. It's edible, but watch your step.
Detailed bug reports welcome.

Quick Start

from apathetic_schema import apathetic_schema, ApatheticSchema_ValidationSummary
from apathetic_utils import schema_from_typeddict
from typing import TypedDict
from pathlib import Path
import json

# Define your config schema using TypedDict
class AppConfig(TypedDict):
    name: str
    version: str
    port: int
    debug: bool

# Load config from JSON
with Path("config.json").open() as f:
    config = json.load(f)

# Validate against TypedDict schema
summary = ApatheticSchema_ValidationSummary(valid=True, errors=[], strict_warnings=[], warnings=[], strict=False)
schema = schema_from_typeddict(AppConfig)

is_valid = apathetic_schema.check_schema_conformance(
    config,
    schema,
    "in configuration file",
    strict_config=False,
    summary=summary,
)

if not summary.valid:
    print("Validation errors:", summary.errors)
    print("Warnings:", summary.warnings)

Installation

# Using poetry
poetry add apathetic-schema

# Using pip
pip install apathetic-schema

Documentation

📚 Full Documentation →

For installation guides, API reference, examples, and more, visit our documentation website.

Features

  • 🔍 TypedDict validation — Validate dict-based configs using Python TypedDicts
  • 📋 Recursive validation — Supports nested TypedDicts and list types
  • ⚠️ Error aggregation — Collect and report validation errors and warnings
  • 🎯 Strict mode — Optional strict validation that treats warnings as errors
  • 🔧 Type-aware — Works with mypy/pyright type annotations
  • 🪶 Minimal dependencies — Only requires apathetic-utils
  • 📝 Helpful errors — Provides context and suggestions for validation failures

⚖️ License

You're free to use, copy, and modify the library under the standard MIT terms.
The additional rider simply requests that this project not be used to train or fine-tune AI/ML systems until the author deems fair compensation frameworks exist.
Normal use, packaging, and redistribution for human developers are unaffected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apathetic_schema-0.1.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apathetic_schema-0.1.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file apathetic_schema-0.1.1.tar.gz.

File metadata

  • Download URL: apathetic_schema-0.1.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for apathetic_schema-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d01212c0b5b09d983064c2ae907672fd41619cfa3954c24fe36493b2f96e2d39
MD5 99bda5f0b5b853d15097f74671c50f5e
BLAKE2b-256 744e8be8faf19907a63b824088904e2f4d1913b42071f9822bab7aea87e605a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for apathetic_schema-0.1.1.tar.gz:

Publisher: publish_pypi.yml on apathetic-tools/python-schema

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file apathetic_schema-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for apathetic_schema-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 60caf4d7966a10f4937d05c2f19b1ce73ff4bfd05d7634d988cbb7862cf381b7
MD5 30ad68fcefb03395ec2911f1efcf8603
BLAKE2b-256 93bb2aa12f4d8649dceefd65159542b20b8247720e2cc04c4848c6064adee318

See more details on using hashes here.

Provenance

The following attestation bundles were made for apathetic_schema-0.1.1-py3-none-any.whl:

Publisher: publish_pypi.yml on apathetic-tools/python-schema

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page