<div align="center">
<a href="https://github.com/anastasds/pydantic-args">
<img src="https://raw.githubusercontent.com/anastasds/pydantic-args/master/docs/assets/images/logo.svg" width="50%">
</a>
<h1>
Pydantic Argparse
</h1>
<p>
<em>Typed Argument Parsing with Pydantic</em>
</p>
<a href="https://pypi.python.org/pypi/pydantic-args">
<img src="https://img.shields.io/pypi/v/pydantic-args.svg">
</a>
<a href="https://pepy.tech/project/pydantic-args">
<img src="https://pepy.tech/badge/pydantic-args">
</a>
<a href="https://github.com/anastasds/pydantic-args">
<img src="https://img.shields.io/pypi/pyversions/pydantic-args.svg">
</a>
<a href="https://github.com/anastasds/pydantic-args/blob/master/LICENSE.md">
<img src="https://img.shields.io/github/license/anastasds/pydantic-args.svg">
</a>
<br>
<a href="https://github.com/anastasds/pydantic-args/actions/workflows/tests.yml">
<img src="https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/tests.yml?label=tests">
</a>
<a href="https://github.com/anastsds/pydantic-args/actions/workflows/tests.yml">
<img src="https://img.shields.io/coveralls/github/anastasds/pydantic-args">
</a>
<a href="https://github.com/anastasds/pydantic-args/actions/workflows/linting.yml">
<img src="https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/linting.yml?label=linting">
</a>
<a href="https://github.com/anastasds/pydantic-args/actions/workflows/typing.yml">
<img src="https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/typing.yml?label=typing">
</a>
</div>
## Help
See [documentation](https://github.com/anastasds/pydantic-args) for help.
## Installation
Installation with `pip` is simple:
```console
$ pip install pydantic-args
```
## Example
```py
import pydantic
import pydantic_args
class Arguments(pydantic.BaseModel):
# Required Args
string: str = pydantic.Field(description="a required string")
integer: int = pydantic.Field(description="a required integer")
flag: bool = pydantic.Field(description="a required flag")
# 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_args.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] --string STRING --integer INTEGER --flag |
--no-flag [--second-flag] [--no-third-flag]
Example Description
required arguments:
--string STRING a required string
--integer INTEGER a required integer
--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 --integer 42 --flag
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": "https://github.com/anastasds/pydantic-args",
"name": "pydantic-args",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "python,pydantic,argparse,typed,validation",
"author": "Hayden Richards",
"author_email": "SupImDos@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/51/9b/5aa4f5865d660664a1d552d28d570fb4d88dbcc39ffb2274c7093f79fe18/pydantic_args-0.9.1.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <a href=\"https://github.com/anastasds/pydantic-args\">\n <img src=\"https://raw.githubusercontent.com/anastasds/pydantic-args/master/docs/assets/images/logo.svg\" width=\"50%\">\n </a>\n <h1>\n Pydantic Argparse\n </h1>\n <p>\n <em>Typed Argument Parsing with Pydantic</em>\n </p>\n <a href=\"https://pypi.python.org/pypi/pydantic-args\">\n <img src=\"https://img.shields.io/pypi/v/pydantic-args.svg\">\n </a>\n <a href=\"https://pepy.tech/project/pydantic-args\">\n <img src=\"https://pepy.tech/badge/pydantic-args\">\n </a>\n <a href=\"https://github.com/anastasds/pydantic-args\">\n <img src=\"https://img.shields.io/pypi/pyversions/pydantic-args.svg\">\n </a>\n <a href=\"https://github.com/anastasds/pydantic-args/blob/master/LICENSE.md\">\n <img src=\"https://img.shields.io/github/license/anastasds/pydantic-args.svg\">\n </a>\n <br>\n <a href=\"https://github.com/anastasds/pydantic-args/actions/workflows/tests.yml\">\n <img src=\"https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/tests.yml?label=tests\">\n </a>\n <a href=\"https://github.com/anastsds/pydantic-args/actions/workflows/tests.yml\">\n <img src=\"https://img.shields.io/coveralls/github/anastasds/pydantic-args\">\n </a>\n <a href=\"https://github.com/anastasds/pydantic-args/actions/workflows/linting.yml\">\n <img src=\"https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/linting.yml?label=linting\">\n </a>\n <a href=\"https://github.com/anastasds/pydantic-args/actions/workflows/typing.yml\">\n <img src=\"https://img.shields.io/github/actions/workflow/status/anastasds/pydantic-args/typing.yml?label=typing\">\n </a>\n</div>\n\n## Help\nSee [documentation](https://github.com/anastasds/pydantic-args) for help.\n\n## Installation\nInstallation with `pip` is simple:\n```console\n$ pip install pydantic-args\n```\n\n## Example\n```py\nimport pydantic\nimport pydantic_args\n\n\nclass Arguments(pydantic.BaseModel):\n # Required Args\n string: str = pydantic.Field(description=\"a required string\")\n integer: int = pydantic.Field(description=\"a required integer\")\n flag: bool = pydantic.Field(description=\"a required flag\")\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_args.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] --string STRING --integer INTEGER --flag |\n --no-flag [--second-flag] [--no-third-flag]\n\nExample Description\n\nrequired arguments:\n --string STRING a required string\n --integer INTEGER a required integer\n --flag, --no-flag 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 --integer 42 --flag\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": "MIT",
"summary": "Typed Argument Parsing with Pydantic",
"version": "0.9.1",
"project_urls": {
"Homepage": "https://github.com/anastasds/pydantic-args",
"Repository": "https://github.com/anastasds/pydantic-args"
},
"split_keywords": [
"python",
"pydantic",
"argparse",
"typed",
"validation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "42df2785c0ff9cc5f1da58aee5046dad8868364483dc986e1f507a727d293947",
"md5": "a737f4530592bb78e7cd121784307490",
"sha256": "2e0bda9b0390069fae6c1c3e4c15b14cc59ecba841552647c69f2e592b9749a0"
},
"downloads": -1,
"filename": "pydantic_args-0.9.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a737f4530592bb78e7cd121784307490",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 25177,
"upload_time": "2024-01-18T16:44:07",
"upload_time_iso_8601": "2024-01-18T16:44:07.037840Z",
"url": "https://files.pythonhosted.org/packages/42/df/2785c0ff9cc5f1da58aee5046dad8868364483dc986e1f507a727d293947/pydantic_args-0.9.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "519b5aa4f5865d660664a1d552d28d570fb4d88dbcc39ffb2274c7093f79fe18",
"md5": "e12eb87f655f2dcf03627bdd1cd0bd26",
"sha256": "20dab8936ac6190bec6821cf4c063abe47848522788c408f6b65d54e12e26eba"
},
"downloads": -1,
"filename": "pydantic_args-0.9.1.tar.gz",
"has_sig": false,
"md5_digest": "e12eb87f655f2dcf03627bdd1cd0bd26",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 16531,
"upload_time": "2024-01-18T16:44:08",
"upload_time_iso_8601": "2024-01-18T16:44:08.523472Z",
"url": "https://files.pythonhosted.org/packages/51/9b/5aa4f5865d660664a1d552d28d570fb4d88dbcc39ffb2274c7093f79fe18/pydantic_args-0.9.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-18 16:44:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "anastasds",
"github_project": "pydantic-args",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pydantic-args"
}