Skip to main content

Type hints → UI metadata. Build forms from Python function signatures.

Project description

pytypeinput 0.1.5

PyPI version Python Tests License

Extract structured metadata from Python type hints.


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 | None with toggle switches
  • Choices: Literal, Enum, Dropdown(func)
  • Constraints: Field(min=, max=, pattern=) for validation
  • Type Composition: Build complex types from simple ones
  • UI Metadata: Custom labels, descriptions, placeholders, sliders, etc.

Renderers:

Reference:

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


Download files

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

Source Distribution

pytypeinput-0.1.5.tar.gz (611.1 kB view details)

Uploaded Source

Built Distribution

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

pytypeinput-0.1.5-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file pytypeinput-0.1.5.tar.gz.

File metadata

  • Download URL: pytypeinput-0.1.5.tar.gz
  • Upload date:
  • Size: 611.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pytypeinput-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8c4804397fa66f2db9d158f3d43795bf7196f2942ada91647c1e89f8f187265c
MD5 f04238b8cd97a99c918d15efb13985a8
BLAKE2b-256 68c075e57344492e1f693bdda901a4e935894a0909cc69e1997b481ae9c1bc32

See more details on using hashes here.

File details

Details for the file pytypeinput-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: pytypeinput-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 28.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for pytypeinput-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b063cd8491e3a2c4044f0898929d4b7344d6c63382248f0761ef7e26a6b3af79
MD5 28de7a2a3e2537846cdc8338ee9eda0f
BLAKE2b-256 be598a4e98a98018146d5dafbb4222fee862b4e8b5771cdde7cb14385b6ea3fe

See more details on using hashes here.

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