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)

Github

Issues

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.4.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.4-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 1d7821543ecb2b0f0f14291c2e75145bd21e3bde0c7bd4d8185be9deb9bc7ad7
MD5 2a87d0dbb8e7746f7a1f8221f87edddb
BLAKE2b-256 87cf97f7c574bfe4ff1a39ea0a72adf3086987d25fa698d918f8170fbe1e5d21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 47d3c1f2966ffac828022caf2ec32cb593b572e250f1e43f06cf3c56fe6fcd60
MD5 0416f7a27d416298faa038c426f76660
BLAKE2b-256 867ee88b384a3176a17c98e2339651d201b868e399d3f28abe1f440031be061c

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