<div align="center">
<!-- Logo -->
<a href="https://pydantic-argparse.supimdos.com"><img src="https://raw.githubusercontent.com/SupImDos/pydantic-argparse/master/docs/assets/images/logo.svg" width="50%"></a>
<!-- Headings -->
<h1>Pydantic Argparse</h1>
<p><em>Typed Argument Parsing with Pydantic</em></p>
<!-- Badges (Row 1) -->
<a href="https://pypi.python.org/pypi/pydantic-argparse"><img src="https://img.shields.io/pypi/v/pydantic-argparse"></a>
<a href="https://pepy.tech/project/pydantic-argparse"><img src="https://img.shields.io/pepy/dt/pydantic-argparse?color=blue"></a>
<a href="https://github.com/SupImDos/pydantic-argparse"><img src="https://img.shields.io/pypi/pyversions/pydantic-argparse"></a>
<a href="https://github.com/SupImDos/pydantic-argparse/blob/master/LICENSE"><img src="https://img.shields.io/github/license/SupImDos/pydantic-argparse"></a>
<br>
<!-- Badges (Row 2) -->
<a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/test.yml?label=tests"></a>
<a href="https://app.codecov.io/github/SupImDos/pydantic-argparse"><img src="https://img.shields.io/codecov/c/github/SupImDos/pydantic-argparse"></a>
<a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/lint.yml"><img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/lint.yml?label=linting"></a>
<a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/format.yml"><img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/format.yml?label=formatting"></a>
<a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/type.yml"><img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/type.yml?label=typing"></a>
</div>
## Help
See [documentation](https://pydantic-argparse.supimdos.com) for help.
## Requirements
Requires Python 3.8+, and is compatible with the Pydantic v1 API.
## Installation
Installation with `pip` is simple:
```console
$ pip install pydantic-argparse
```
## Example
```py
import pydantic.v1 as pydantic
import pydantic_argparse
class Arguments(pydantic.BaseModel):
# Required Args
string: str = pydantic.Field(description="a required string", aliases=["-s"])
integer: int = pydantic.Field(description="a required integer", aliases=["-i"])
flag: bool = pydantic.Field(description="a required flag", aliases=["-f"])
# Optional Args
second_flag: bool = pydantic.Field(False, description="an optional flag")
third_flag: bool = pydantic.Field(True, description="an optional flag")
def main() -> None:
# Create Parser and Parse Args
parser = pydantic_argparse.ArgumentParser(
model=Arguments,
prog="Example Program",
description="Example Description",
version="0.0.1",
epilog="Example Epilog",
)
args = parser.parse_typed_args()
# Print Args
print(args)
if __name__ == "__main__":
main()
```
```console
$ python3 example.py --help
usage: Example Program [-h] [-v] [-s STRING] [-i INTEGER] [-f | --flag | --no-flag]
[--second-flag] [--no-third-flag]
Example Description
required arguments:
-s STRING, --string STRING
a required string
-i INTEGER, --integer INTEGER
a required integer
-f, --flag, --no-flag
a required flag
optional arguments:
--second-flag an optional flag (default: False)
--no-third-flag an optional flag (default: True)
help:
-h, --help show this help message and exit
-v, --version show program's version number and exit
Example Epilog
```
```console
$ python3 example.py --string hello -i 42 -f
string='hello' integer=42 flag=True second_flag=False third_flag=True
```
## License
This project is licensed under the terms of the MIT license.
Raw data
{
"_id": null,
"home_page": null,
"name": "pydantic-argparse",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "argparse, pydantic, python, typed, validation",
"author": null,
"author_email": "Hayden Richards <supimdos@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/94/ea/e63d587294c20d3b83e9c312b5d577c9ec28962ee8490839ca9996672849/pydantic_argparse-0.10.0.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n<!-- Logo -->\n<a href=\"https://pydantic-argparse.supimdos.com\"><img src=\"https://raw.githubusercontent.com/SupImDos/pydantic-argparse/master/docs/assets/images/logo.svg\" width=\"50%\"></a>\n<!-- Headings -->\n<h1>Pydantic Argparse</h1>\n<p><em>Typed Argument Parsing with Pydantic</em></p>\n<!-- Badges (Row 1) -->\n<a href=\"https://pypi.python.org/pypi/pydantic-argparse\"><img src=\"https://img.shields.io/pypi/v/pydantic-argparse\"></a>\n<a href=\"https://pepy.tech/project/pydantic-argparse\"><img src=\"https://img.shields.io/pepy/dt/pydantic-argparse?color=blue\"></a>\n<a href=\"https://github.com/SupImDos/pydantic-argparse\"><img src=\"https://img.shields.io/pypi/pyversions/pydantic-argparse\"></a>\n<a href=\"https://github.com/SupImDos/pydantic-argparse/blob/master/LICENSE\"><img src=\"https://img.shields.io/github/license/SupImDos/pydantic-argparse\"></a>\n<br>\n<!-- Badges (Row 2) -->\n<a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/test.yml\"><img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/test.yml?label=tests\"></a>\n<a href=\"https://app.codecov.io/github/SupImDos/pydantic-argparse\"><img src=\"https://img.shields.io/codecov/c/github/SupImDos/pydantic-argparse\"></a>\n<a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/lint.yml\"><img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/lint.yml?label=linting\"></a>\n<a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/format.yml\"><img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/format.yml?label=formatting\"></a>\n<a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/type.yml\"><img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/type.yml?label=typing\"></a>\n</div>\n\n## Help\nSee [documentation](https://pydantic-argparse.supimdos.com) for help.\n\n## Requirements\nRequires Python 3.8+, and is compatible with the Pydantic v1 API.\n\n## Installation\nInstallation with `pip` is simple:\n```console\n$ pip install pydantic-argparse\n```\n\n## Example\n```py\nimport pydantic.v1 as pydantic\n\nimport pydantic_argparse\n\n\nclass Arguments(pydantic.BaseModel):\n # Required Args\n string: str = pydantic.Field(description=\"a required string\", aliases=[\"-s\"])\n integer: int = pydantic.Field(description=\"a required integer\", aliases=[\"-i\"])\n flag: bool = pydantic.Field(description=\"a required flag\", aliases=[\"-f\"])\n\n # Optional Args\n second_flag: bool = pydantic.Field(False, description=\"an optional flag\")\n third_flag: bool = pydantic.Field(True, description=\"an optional flag\")\n\n\ndef main() -> None:\n # Create Parser and Parse Args\n parser = pydantic_argparse.ArgumentParser(\n model=Arguments,\n prog=\"Example Program\",\n description=\"Example Description\",\n version=\"0.0.1\",\n epilog=\"Example Epilog\",\n )\n args = parser.parse_typed_args()\n\n # Print Args\n print(args)\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n```console\n$ python3 example.py --help\nusage: Example Program [-h] [-v] [-s STRING] [-i INTEGER] [-f | --flag | --no-flag]\n [--second-flag] [--no-third-flag]\n\nExample Description\n\nrequired arguments:\n -s STRING, --string STRING\n a required string\n -i INTEGER, --integer INTEGER\n a required integer\n -f, --flag, --no-flag\n a required flag\n\noptional arguments:\n --second-flag an optional flag (default: False)\n --no-third-flag an optional flag (default: True)\n\nhelp:\n -h, --help show this help message and exit\n -v, --version show program's version number and exit\n\nExample Epilog\n```\n\n```console\n$ python3 example.py --string hello -i 42 -f\nstring='hello' integer=42 flag=True second_flag=False third_flag=True\n```\n\n## License\nThis project is licensed under the terms of the MIT license.\n",
"bugtrack_url": null,
"license": null,
"summary": "Typed Argument Parsing with Pydantic",
"version": "0.10.0",
"project_urls": {
"Changelog": "https://github.com/SupImDos/pydantic-argparse/blob/master/CHANGELOG.md",
"Documentation": "https://pydantic-argparse.supimdos.com",
"Homepage": "https://pydantic-argparse.supimdos.com",
"Issues": "https://github.com/SupImDos/pydantic-argparse/issues",
"Repository": "https://github.com/SupImDos/pydantic-argparse"
},
"split_keywords": [
"argparse",
" pydantic",
" python",
" typed",
" validation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "be149ee71e3a183f76ff93e46b36157d6ddbf29ec2547b7d2c57931cd5d3aecc",
"md5": "5e2349e2253d1065ea675e5fb8782b3a",
"sha256": "e317f001208d77a5600ece6f7ac78d768d8221a7d64a958980705e9630c2e299"
},
"downloads": -1,
"filename": "pydantic_argparse-0.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5e2349e2253d1065ea675e5fb8782b3a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 25265,
"upload_time": "2025-02-09T08:18:27",
"upload_time_iso_8601": "2025-02-09T08:18:27.671661Z",
"url": "https://files.pythonhosted.org/packages/be/14/9ee71e3a183f76ff93e46b36157d6ddbf29ec2547b7d2c57931cd5d3aecc/pydantic_argparse-0.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "94eae63d587294c20d3b83e9c312b5d577c9ec28962ee8490839ca9996672849",
"md5": "b21ae3949360d229d013edd6223f53e0",
"sha256": "d57eb0a84c8f0af6605376157d3f445cfd786700f2e596ba9d48d15d557185eb"
},
"downloads": -1,
"filename": "pydantic_argparse-0.10.0.tar.gz",
"has_sig": false,
"md5_digest": "b21ae3949360d229d013edd6223f53e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 15928,
"upload_time": "2025-02-09T08:18:30",
"upload_time_iso_8601": "2025-02-09T08:18:30.425815Z",
"url": "https://files.pythonhosted.org/packages/94/ea/e63d587294c20d3b83e9c312b5d577c9ec28962ee8490839ca9996672849/pydantic_argparse-0.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-09 08:18:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SupImDos",
"github_project": "pydantic-argparse",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pydantic-argparse"
}