Framework-free browser form layer for pytypehint
Project description
pytypehintweb
pytypehintweb is a framework-free browser form layer for
pytypehint. It converts compiled
Python type schemas into self-contained, JSON-serializable form plans and
renders them with plain JavaScript widgets. The browser runtime also consumes
hand-written plans or plans from another backend, so Python is not required at
render time. Everything around the form — routing, static-file delivery,
authentication, submission, function execution — belongs to the host
application. (For the whole request/response cycle instead of the rendering
layer, see FuncToWeb.)
Pre-1.0: the API is still settling, so breaking changes are expected between releases.
Features
- Self-contained, JSON-serializable plans from plain functions, dataclass types
or compiled
Signature/Structschemas — and hand-written plans need no Python. - Framework-free browser runtime (plain HTML, CSS and JS modules), with widgets
usable directly or from a plan; browser files ship inside the Python package
under
pytypehintweb.STATIC. str,int,float,date,time,boolandenumcomposing through lists, optional fields, unions and nested dataclasses, with constraints, static choices, integer sliders, and configurable validation messages and labels.filefields (single orlist[File]) that mint an upload reference the host redeems through its own channel.- Centralized plan normalization and validation before any widget is built, and
plain/inline/wrappedunion transport. - Plan text is always rendered as text, never parsed as markup.
Installation
pip install pytypehintweb # library
pip install "pytypehintweb[demo]" # + the local demo (pytypehintweb-demo)
# Demo with all widgets, served by a local HTTP server on port 8000:
pytypehintweb-demo
There is no npm package: the browser modules live under pytypehintweb.STATIC
and can be served by any static-file mount.
Quick start
from typing import Annotated
from pytypehint import Label, Min
from pytypehintweb import plan_of
def create_user(
username: Annotated[str, Min(3), Label("Username")],
age: Annotated[int, Min(0), Label("Age")],
) -> None:
pass
plan = plan_of(create_user)
plan_of() returns ordinary Python dictionaries and lists — a single, fully
expanded, self-contained document where every non-conditional property is present
with an explicit value (default appears exactly when hasDefault is true),
carrying a top-level "v": 1:
{
"v": 1,
"kind": "form",
"name": "create_user",
"description": null,
"fields": [
{
"name": "username",
"label": "Username",
"description": null,
"optional": false,
"enabled": true,
"hasDefault": false,
"node": {
"kind": "str",
"options": {
"minLength": 3,
"maxLength": null,
"pattern": null,
"patternMessage": "Invalid format",
"minMessage": "Must contain at least {value} characters",
"maxMessage": "Must contain at most {value} characters",
"placeholder": null,
"password": false,
"rows": null,
"choices": null
}
}
},
{
"name": "age",
"label": "Age",
"description": null,
"optional": false,
"enabled": true,
"hasDefault": false,
"node": {
"kind": "int",
"options": {
"min": 0,
"max": null,
"multipleOf": null,
"step": null,
"slider": false,
"showValue": false,
"placeholder": null,
"choices": null,
"safeMessage": "Must be a safe integer",
"invalidMessage": "Enter a valid integer",
"minMessage": "Must be at least {value}",
"maxMessage": "Must be at most {value}",
"multipleOfMessage": "Must be a multiple of {value}",
"increaseLabel": "Increase",
"decreaseLabel": "Decrease"
}
}
}
]
}
Transporting that document to the browser and compiling it with compileForm()
is walked through end to end in Getting started.
Documentation
- Getting started — the end-to-end tutorial.
- Plan contract — the plan format, every property and invariant.
- Python API —
plan_of(),WebConfig, annotation mappings. - JavaScript API —
compileForm(), widgets, reading, accessibility, styling. - Architecture — layers and which layer owns each rule.
- Testing — how to run the suites and what they guarantee.
- Current limitations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytypehintweb-0.0.1.tar.gz.
File metadata
- Download URL: pytypehintweb-0.0.1.tar.gz
- Upload date:
- Size: 77.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3965f683a54c6c4c49c944a8192b63138f8cc7c2909bed23a1784b20820b7278
|
|
| MD5 |
61eb8cad72d87c9001b592e956c17fa3
|
|
| BLAKE2b-256 |
bd189198a200d3d25e603a1637222eb9efd7dcc188eb67917c870696f922e83a
|
Provenance
The following attestation bundles were made for pytypehintweb-0.0.1.tar.gz:
Publisher:
publish.yml on offerrall/pytypehintweb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytypehintweb-0.0.1.tar.gz -
Subject digest:
3965f683a54c6c4c49c944a8192b63138f8cc7c2909bed23a1784b20820b7278 - Sigstore transparency entry: 2231546374
- Sigstore integration time:
-
Permalink:
offerrall/pytypehintweb@f372eb99525c110b5fda39a94e216e1dba5bfd2e -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/offerrall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f372eb99525c110b5fda39a94e216e1dba5bfd2e -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytypehintweb-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pytypehintweb-0.0.1-py3-none-any.whl
- Upload date:
- Size: 80.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d6141e2263c1a6d57e93b2d7b6045fec8049e511dff947193427ac2c9c0184f
|
|
| MD5 |
120ca32beaa9ba0c89f38f29c546b5fd
|
|
| BLAKE2b-256 |
c061c5c4d953cc8daf60503d19b72db09748f2986cface2886cc678918b40546
|
Provenance
The following attestation bundles were made for pytypehintweb-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on offerrall/pytypehintweb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytypehintweb-0.0.1-py3-none-any.whl -
Subject digest:
1d6141e2263c1a6d57e93b2d7b6045fec8049e511dff947193427ac2c9c0184f - Sigstore transparency entry: 2231546919
- Sigstore integration time:
-
Permalink:
offerrall/pytypehintweb@f372eb99525c110b5fda39a94e216e1dba5bfd2e -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/offerrall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f372eb99525c110b5fda39a94e216e1dba5bfd2e -
Trigger Event:
release
-
Statement type: