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.5.0.tar.gz (62.4 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.5.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for airfield-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2167ddcf49e66cadab8c20d5d377e437b89364dd2cc509a27154294aea32c280
MD5 11378f0bc9fba5b35203be1514f16543
BLAKE2b-256 849f271f1adf6c984616037e2371705b2006d677092d51b46e2b6fda2f6e3aff

See more details on using hashes here.

Provenance

The following attestation bundles were made for airfield-0.5.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: airfield-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9572490430c1a6525ad77fbb6ecd1cc94597412f55f91c02ab4785a81c80472d
MD5 3af983d179332187291eb90b5b1a587b
BLAKE2b-256 2fb30d798c6cc2cc7304994f10e8c144109d7989a0a96a712598f6a4279728d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for airfield-0.5.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