Skip to main content

Pydantic 2 argparse.

Project description

pydantic-argparse-next

Argument parser based on pydantic v2.

Install:

pip install pydantic-argparse-next

Base usage:

from pydantic import BaseModel, Field
import pydantic_argparse_next as pa


class Temp(BaseModel):
    # Positional arguments
    a: str = pa.Arg(description="This is a required positional argument.")
    b: str = pa.Arg("defalut_value", description="This is a OPTIONAL positional argument.")

    # Keyword arguments
    # Simple attributes or pydantic.Field are keyword arguments.
    c: str
    d: str = Field(None, description="This is a OPTIONAL keyword argument.")
    e: str = pa.KwArg(description="This is a required keyword argument.")
Input: appname "test1" --c "test2" --e="test3"
Output: a='test1' b='defalut_value' c='test2' d=None e='test3'

More details in the documentation

Supports:

✅ Positional arguments

        ✅ Required positional arguments

        ✅ Optional positional arguments

✅ Keyword arguments

        ✅ Required keyword arguments

        ✅ Optional keyword arguments

✅ Subcommands

        ✅ Required subcommands

        ✅ Optional subcommands

        ✅ Subcommands within subcommands

✅ Actions

        ✅ Choice (And simple text and Enum object)

        ✅ Store True

        ✅ Store False

        ✅ Variadic arguments

⬜ Extra

        ⬜ Easy saving config to file

        ⬜ Easy load config from file

More details in the documentation

Docs and examples:

  1. Base usage

  2. Actions

    1. Choice

    2. Store True and Store False

    3. Subcommands

    4. Variadic

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_argparse_next-1.0.6.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

pydantic_argparse_next-1.0.6-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_argparse_next-1.0.6.tar.gz.

File metadata

  • Download URL: pydantic_argparse_next-1.0.6.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.4 Windows/11

File hashes

Hashes for pydantic_argparse_next-1.0.6.tar.gz
Algorithm Hash digest
SHA256 ee6e06fb1257c8010252c226ee5acc809c0c0f4dad963268deef6579cafcba97
MD5 84ddab94f885328a80a331ad3a74d15f
BLAKE2b-256 fccd25a208e1c2d5a631945676479dfd1da39963c684666e4494d5a17ad96884

See more details on using hashes here.

File details

Details for the file pydantic_argparse_next-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_argparse_next-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7c6c9548412928d06e2bbaaafcab26934537c6d7e37f7d8ca9d24920c9ace4ff
MD5 544193ebb320227534411969c7ae998b
BLAKE2b-256 4f317306a8b90af484956c5503976c270cf22a55fd7cf0899d81344c4db0d7ff

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