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:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_argparse_next-1.0.7.tar.gz.
File metadata
- Download URL: pydantic_argparse_next-1.0.7.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da703053ed528a49f952aca95a8907eb7241b79bea80c99dc13dc62188bb582f
|
|
| MD5 |
e273f7062981fb3f0d8b0fac2a2ecb66
|
|
| BLAKE2b-256 |
b7416a6a968981f1f98121ae08ba9a859e8f91a238d46739ebb95b4d2aecb249
|
File details
Details for the file pydantic_argparse_next-1.0.7-py3-none-any.whl.
File metadata
- Download URL: pydantic_argparse_next-1.0.7-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.4 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8c43680f2942038ecf6428c611e033275775e10f561cb7b8fb8735f5dfda983
|
|
| MD5 |
522f630cfc4dc82abb027857624ca0d6
|
|
| BLAKE2b-256 |
4d13d8d2a57e265ffa32b983a10810b0ec9ff0292a9ae63272f7dfeade51bbab
|