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.5.tar.gz (14.2 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.5-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.5.tar.gz
  • Upload date:
  • Size: 14.2 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.5.tar.gz
Algorithm Hash digest
SHA256 3087974f3945ad9a1e02e0b2a751a1684ba3b768cb83ad7ad9ebfcb5ec7de0db
MD5 a478aa7e424cc4d179ab43aa8cc1ca06
BLAKE2b-256 f495c15832c3f496a6f057bd2d585086f8e70dd9ab60294673f0b00aa3834fc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7dc036ab319aa5af3f5556e9e2d6aadc7172c4a316d256a4e673e7cc97f839d9
MD5 28632e751e48cdd95767e390eb442653
BLAKE2b-256 1933d962070548f14c1d6e1e18a9f7dcc0494e45235f0d8a6867893ef80f7987

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