Skip to main content

Parse cli arguments directly into Pydantic models with help from click!

Project description

Pydantic CLI Models

Pydantic + Click == Perfection (with love to Rust's clap library)

Reduce boilerplate by 2x (at least), turning this:

import click
from pydantic import BaseModel

class Person(BaseModel):
    name: str
    age: int

@click.command()
@click.option("--name", type=str)
@click.option("--age", type=int)
def main(name, age):
    person = Person(name=name, age=age)
    # ... do something with person ...

Into this:

from pydantic_cli_model import CLIModel


class Person(CLIModel):
    name: str
    age: int

@Person.cli
def main(person:Person):
    ...
    # ... do something with person ...

And get data validation for free!

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

pydantic_cli_model-0.1.3.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

pydantic_cli_model-0.1.3-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_cli_model-0.1.3.tar.gz.

File metadata

  • Download URL: pydantic_cli_model-0.1.3.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for pydantic_cli_model-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3a17c2aad84a36d8d5620811d55e8695791c88b54484a6a2635d588586413eb7
MD5 3d34e9e4236b77d4fc989aa496f801f1
BLAKE2b-256 e3b78d2c9b63ce8b97e6042b6daa69d1941064046f022d0e648a90e389e7f98f

See more details on using hashes here.

File details

Details for the file pydantic_cli_model-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pydantic_cli_model-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for pydantic_cli_model-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5db6fd28334410eff87449a4bfaf81dcd59615593d709d4c481e8de62362152e
MD5 a254703f53ebb26920dd0f5083e20865
BLAKE2b-256 6dbc3959e94a50af236175637dc9c4714510e0a19a01cfd847143c9d34624cc6

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