pydantic-argparse
Typed Argument Parsing with Pydantic
Help
Documentation coming soon.
Installation
Install using:
pip3 install pydantic-argparse
Example
import pydantic
import pydantic_argparse
class Arguments(pydantic.BaseModel):
"""Arguments for CLI"""
# Required Args
aaa: str = pydantic.Field(description="I'm a required string")
bbb: int = pydantic.Field(description="I'm a required integer")
ccc: bool = pydantic.Field(description="I'm a required bool")
# Optional Args
ddd: bool = pydantic.Field(False, description="I'm an optional bool (default False)")
eee: bool = pydantic.Field(True, description="I'm an optional bool (default True)")
def main() -> None:
"""Main example function."""
# Create Parser and Parse Args
parser = pydantic_argparse.ArgumentParser(
model=Arguments,
prog="Example",
description="Example Description",
version="0.0.1",
epilog="Example Epilog",
)
args = parser.parse_typed_args()
# Print Args
print(args)
if __name__ == "__main__":
main()
$ python3 example.py --help
usage: Example [-h] [-v] --aaa AAA --bbb BBB --ccc | --no-ccc [--ddd] [--no-eee]
Example Description
required arguments:
--aaa AAA I'm a required string
--bbb BBB I'm a required integer
--ccc, --no-ccc I'm a required bool
optional arguments:
--ddd I'm an optional bool (default False)
--no-eee I'm an optional bool (default True)
help:
-h, --help show this help message and exit
-v, --version show program's version number and exit
Example Epilog
$ python3 example.py --aaa hello --bbb 123 --no-ccc
aaa='hello' bbb=123 ccc=False ddd=False eee=True
Metadata
Release files for pydantic-argparse 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pydantic-argparse-0.3.1.tar.gz | 11.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_argparse-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.8 kB
Release files / pydantic-argparse-0.3.1.tar.gz
| Download URL | pydantic-argparse-0.3.1.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ea99b34f35c6446c5f9be7d5af76e5d93ab3aab8fea3e87647f67f8459c8ea0
|
|
BLAKE2b-256 checksum How to use checksums |
9b3b8c0df6232157b99905d2e07517048d80c3b9557f1ed559de8aa3755cbb5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.1 Darwin/21.1.0
|
Release files / pydantic_argparse-0.3.1-py3-none-any.whl
| Download URL | pydantic_argparse-0.3.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f59cc6434574491fb5642eebab4f6f772442d7f37d4abfa70a3907700fadfa6
|
|
BLAKE2b-256 checksum How to use checksums |
680b4ec7bd94ee5c861c6fabc23de2d70107c83b25f5a25acf753dc8bc26cb20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.1 Darwin/21.1.0
|
Security for pydantic-argparse 0.3.1
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.