Skip to main content

Dataclasses that describe how Pydantic model fields should be presented in any UI context: web forms, CLI prompts, data tables, notebooks, API docs, charts.

Project description

AirField

PyPI version

Dataclasses that describe how Pydantic model fields should be presented in any UI context: web forms, CLI prompts, data tables, notebooks, API docs, charts.

Features

annotated-types is for validation. AirField is for presentation. Pydantic reads both.

from pydantic import BaseModel
from airfield import AirField, Label, Widget, Autofocus, PrimaryKey

class Article(BaseModel):
    id: int = AirField(primary_key=True)
    title: str = AirField(label="Title", autofocus=True)
    email: str = AirField(type="email", label="Email Address")
    body: str = AirField(widget="textarea", placeholder="Write something...")

Note: AirField works with any Pydantic BaseModel. If you're using Air, use AirModel instead, which extends BaseModel with ORM and form support.

Every parameter produces a typed, frozen dataclass in field_info.metadata. Consumers discover metadata with isinstance checks:

for m in field_info.metadata:
    if isinstance(m, Widget):
        render_input(m.kind)
    elif isinstance(m, Label):
        render_label(m.text)
    elif isinstance(m, PrimaryKey):
        make_read_only()

Two ways to declare, same result:

# Convenience function
email: str = AirField(type="email", label="Email")

# Annotated metadata (composable with annotated-types, etc.)
email: Annotated[str, Widget("email"), Label("Email")]

Presentation types

Type Purpose
PrimaryKey Field is the record identity (affects visibility, editability, linking)
Label Human-readable display name
Placeholder Hint text when the field is empty
HelpText Explanatory text that supplements the label
Widget Preferred input mechanism ("email", "textarea", "date", ...)
DisplayFormat How to format the value for display ("currency", "percent", ...)
Choices Constrain to labeled options (select, radio, combobox)
Autofocus This field receives focus when the UI loads
Hidden Field is not shown in specified contexts
ReadOnly Field is displayed but not editable
Filterable Field appears in search/filter UI
Sortable Field is sortable in list/table views
ColumnAlign Left/center/right alignment in tables
ColumnWidth Relative width in table columns
Grouped Assigns to a named group for layout
Priority Importance relative to siblings
Compact How to represent in space-constrained contexts

Documentation

Documentation is built with Zensical and deployed to GitHub Pages.

API documentation is auto-generated from docstrings using mkdocstrings.

Docs deploy automatically on push to main via GitHub Actions. To enable this, go to your repo's Settings > Pages and set the source to GitHub Actions.

Development

To set up for local development:

# Clone your fork
git clone git@github.com:your_username/AirField.git
cd AirField

# Install in editable mode with live updates
uv tool install --editable .

This installs the CLI globally but with live updates - any changes you make to the source code are immediately available when you run airfield.

Run tests:

uv run pytest

Run quality checks (format, lint, type check, test):

just qa

Author

AirField was created in 2026 by Audrey M. Roy Greenfeld.

Built with Cookiecutter and the audreyfeldroy/cookiecutter-pypackage project template.

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

airfield-0.4.0.tar.gz (61.9 kB view details)

Uploaded Source

Built Distribution

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

airfield-0.4.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file airfield-0.4.0.tar.gz.

File metadata

  • Download URL: airfield-0.4.0.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airfield-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1199c0ac9dadd3c1eadd4c9f8606184932e94acda9924f12b07f05231e004c1c
MD5 e7aa30ffb7e7f9caf4ef694a1d90612a
BLAKE2b-256 5b4cf8000d0c8e75ad283afef3b2a1b5d612947ad312f2baf13aa5aaa1c5bfc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for airfield-0.4.0.tar.gz:

Publisher: publish.yml on feldroy/AirField

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

File details

Details for the file airfield-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: airfield-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for airfield-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03285e65180b02076f3c2d56ee57b7fa8220406c945893f921f71faf7e9f4462
MD5 75c79e9cd8d9dac03d6e7e4ec60a2384
BLAKE2b-256 4a01ab36936051e8604b5b7a97d6e3c24ef7eebc7c114a22b4ebfaf72d56e26f

See more details on using hashes here.

Provenance

The following attestation bundles were made for airfield-0.4.0-py3-none-any.whl:

Publisher: publish.yml on feldroy/AirField

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