Skip to main content

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

Project description

Pydantic CLI Models

Pydantic + Click == Perfection.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ce938fc867953cfa84c38b5e6484827608983037dd4fa4722601f812e9cf35d1
MD5 a5811ca1f63c801ed24b9e87c09ca2e5
BLAKE2b-256 33d7e14e41038507ba439e0d175511e2d1054fbe3d5e19a7a5750a7ac3bc1c45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pydantic_cli_model-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5793988eab6e3babab917b45e3d15a4eb541067e106ff7e8d4b8511c763a37f4
MD5 2d3f7f4296105f3093c91dc894131f1d
BLAKE2b-256 03cc430bc0d74db062afd80bd6d4c4b10e104563e8c466b7978e522a9dc331ea

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