Skip to main content

p2a

pydantic models to argparse CLIs

Build Status codecov License PyPI

Overview

A function is provided to automatically expose fields as command line arguments.

import sys
from pydantic import BaseModel
from p2a import parse_extra_args_model


class MyPluginConfig(BaseModel, validate_assignment=True):
    extra_arg: bool = False
    extra_arg_with_value: str = "default"
    extra_arg_literal: Literal["a", "b", "c"] = "a"


model = MyPluginConfig()
parse_extra_args_model(model, sys.argv)

# > my-cli --extra-arg --extra-arg-with-value "test" --extra-arg-literal b

For integration with existing argparse CLIs, a helper function to create an argparse.SubParser is also provided: p2a.create_model_parser.

Metadata

Release files for p2a 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for p2a 0.1.2
File Size Uploaded Provenance
p2a-0.1.2.tar.gz 13.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for p2a 0.1.2
File Interpreter ABI Platform
p2a-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.9 kB

Release files / p2a-0.1.2.tar.gz

Download URL p2a-0.1.2.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
86bead4ed95e52d0fc48dcb429e2a03f08013393226d641eb9580e77de24d00a
BLAKE2b-256 checksum
How to use checksums
43be0efe398eea1b018f16c0673e237dc813b33520185617716281108c9e2e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / p2a-0.1.2-py3-none-any.whl

Download URL p2a-0.1.2-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f671e93a9682d51183e61d20a4f5971e8916b41f70c4c488f745e5c9bbb9c6e
BLAKE2b-256 checksum
How to use checksums
6e0cd80bdb49e1d9d7b559ca9bee439ba3170a630f51f8f63afeddc0bbb3960f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for p2a 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page