Type hints → UI metadata. Build forms from Python function signatures.
Project description
pytypeinput 0.1.2
pytypeinput analyzes Python type hints and extracts structured metadata. Use this metadata to build UIs, CLIs, config editors, or anything that needs input specifications.
from dataclasses import dataclass
from pytypeinput import Field, Annotated, analyze_dataclass
@dataclass
class User:
username: Annotated[str, Field(min_length=3, max_length=20)]
age: Annotated[int, Field(ge=18, le=120)]
bio: str | None = None
# Extract metadata
params = analyze_dataclass(User)
# Use it to build: HTML forms, CLIs, GUIs, validators...
Design Goals
- Single source of truth - Define once with type hints, use everywhere (forms, CLIs, validation)
- Minimal code - Maximum features with minimum boilerplate
- Type-safe - Full IDE autocomplete and type checking
- Pure Python - Build UIs with Python code, not templates or DSLs
Installation
Core only:
pip install pytypeinput
With HTML renderer:
pip install pytypeinput[html]
Requirements: Python 3.10+ • Pydantic 2.0+
Documentation
Complete Documentation with interactive examples
Type System:
- Basic Types:
int,float,str,bool,date,time - Special Types:
Email,Color,File,ImageFile, etc. - Lists:
list[Type]with item and list-level validation - Optionals:
Type | Nonewith toggle switches - Choices:
Literal,Enum,Dropdown(func) - Constraints:
Field(min=, max=, pattern=)for validation - UI Metadata: Custom labels, descriptions, placeholders, sliders, etc.
Renderers:
- HTML Renderer - Generate forms with client-side validation
Reference:
- API Reference - Complete API documentation
What pytypeinput does
✅ Extracts metadata from type hints
✅ Works with functions, dataclasses, Pydantic models, classes
✅ Optional HTML renderer with client-side validation
✅ Framework-agnostic
❌ No server-side validation
❌ No form submission handling
pytypeinput is a building block, not a complete solution.
Validation: Type hints validated when extracting metadata. HTML forms validate client-side. Server-side is your responsibility (use Pydantic with same type hints).
Contributing
Found a bug or have a suggestion? Open an issue
License
MIT • Beltrán Offerrall
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 pytypeinput-0.1.2.tar.gz.
File metadata
- Download URL: pytypeinput-0.1.2.tar.gz
- Upload date:
- Size: 479.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f1c64b29fe32ca0548a02edffb08808cdb7a7d97dff3da5232f75214c0f85a2
|
|
| MD5 |
9b340e63a4c4f98ef0f043eed1263d13
|
|
| BLAKE2b-256 |
71ff4fafcd11f4c1be130d1c52236bbf41d5a5f566f15f9a2dfc41cfffdcdf35
|
File details
Details for the file pytypeinput-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pytypeinput-0.1.2-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9e50a9cd1bb2cd7af26d414829a207833e9f06225f1ff9911894f5536580a5c
|
|
| MD5 |
3a80041aaf0df42354b643c9c322a108
|
|
| BLAKE2b-256 |
da19b6054495021a05d0d625dd3fec6ec21e4747fdd4afe17b6a36c8d12ebb77
|