Skip to main content

Runtime type validation for Python

Project description

TypeWall

GitHub stars PyPI version Python versions License CI

TypeWall is a lightweight, schema-first runtime validation library for Python 3.9 through 3.14. It provides strict parsing, deterministic structured errors, immutable schemas, composition, custom processing, type-derived schemas, boundary adapters, and optional FastAPI integration.

Installation

pip install typewall
pip install "typewall[fastapi]"  # optional FastAPI integration

Quick Start

from typewall import w

User = w.object({
    "name": w.str().min(2),
    "age": w.int().min(0).optional(),
    "tags": w.list(w.str()).default([]),
})

user = User.parse({"name": "Ada"})
assert user == {"name": "Ada", "tags": []}

TypeWall is strict: it does not coerce "42" into 42. Use explicit boundary adapters such as parse_env() when text conversion is required.

Error Inspection

result = User.safe_parse({"name": 42})
if not result.ok:
    for issue in result.errors:
        print(issue.path, issue.code, issue.message)

parse() raises one ValidationError containing every independently reachable issue. safe_parse() returns the same ordered issues without raising.

Integrations

  • JSON Schema 2020-12: to_json_schema(schema)
  • OpenAPI 3.1 schema objects: to_openapi_schema(schema)
  • Environment mappings: ObjectSchema.parse_env()
  • CLI: typewall validate module:attribute [path|-]
  • FastAPI: typewall.integrations.fastapi.request_body()

See the documentation, guides, and runnable examples. The documentation site is a self-contained Mintlify project under docs/; preview it locally with cd docs && npm install && npm run dev. Development and benchmark commands are documented in the contributing guide.

Development

uv sync --all-groups --all-extras --python 3.14
uv run pytest
uv run ruff format --check .
uv run ruff check .
uv run mypy
uv run pyright
uv run pytest benchmarks --benchmark-only

Contributing

Contributions go through a fork-based pull request workflow:

  1. Fork MyGenX/TypeWall to your account.
  2. Work on a feature branch in your fork, running the local checks above.
  3. Open a PR from your branch against MyGenX/TypeWall:main.
  4. Address review feedback and get it merged.

See CONTRIBUTING.md and the contributing guide for the full workflow and required checks.

TypeWall is distributed under the MIT license.

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

typewall-0.2.0.tar.gz (152.5 kB view details)

Uploaded Source

Built Distribution

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

typewall-0.2.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file typewall-0.2.0.tar.gz.

File metadata

  • Download URL: typewall-0.2.0.tar.gz
  • Upload date:
  • Size: 152.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for typewall-0.2.0.tar.gz
Algorithm Hash digest
SHA256 76685bfbf6c585721f95f5b2f7c89407ff20672040bf3ae8d434bae801ed3bcd
MD5 d236c67aae7183698416889779682072
BLAKE2b-256 08bff024d4aa71527f3a45ddb034a9ba5c25586a67a074efd14cd02d06cec23b

See more details on using hashes here.

Provenance

The following attestation bundles were made for typewall-0.2.0.tar.gz:

Publisher: pypi-release.yml on MyGenX/TypeWall

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

File details

Details for the file typewall-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: typewall-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for typewall-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8dfd21874326e8437fd7880fc61bb681db8e5c8cc713921ceb0670180c0b643f
MD5 6d8c8fb6729ead8dd4094f30ec01220c
BLAKE2b-256 04d7830e130ceacd5f455fd982371bca77180d78f1658f4a1c0252be49e95c71

See more details on using hashes here.

Provenance

The following attestation bundles were made for typewall-0.2.0-py3-none-any.whl:

Publisher: pypi-release.yml on MyGenX/TypeWall

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