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.1.tar.gz (154.1 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.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typewall-0.2.1.tar.gz
  • Upload date:
  • Size: 154.1 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.1.tar.gz
Algorithm Hash digest
SHA256 5e71ab37b52dde34f2efa989a612380cd2120d004d9671cfe8b6b225a4660ef5
MD5 1bdfb1db802f8c17387469e5d8c4b553
BLAKE2b-256 9bcffdf44a33ab32d880ab8273600cd97de61e7fd9066591bdb106ec14f6e58f

See more details on using hashes here.

Provenance

The following attestation bundles were made for typewall-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: typewall-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 25.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 859898ce375a2161e4d35c4ee7fe789f1efbf9302d48cd9444e5d4568ed4e8af
MD5 c07759d4974b08e1190cddb9a829b546
BLAKE2b-256 30340b1af56f0aea51e36db0357510dc9a99397cd55b0e2e63e2aff410d6cb21

See more details on using hashes here.

Provenance

The following attestation bundles were made for typewall-0.2.1-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