pydantic-argparse


Namepydantic-argparse JSON
Version 0.9.0 PyPI version JSON
download
home_pageNone
SummaryTyped Argument Parsing with Pydantic
upload_time2024-04-29 08:39:52
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2021 Hayden Richards Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords argparse pydantic python typed validation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
    <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>
    <h1>
        Pydantic Argparse
    </h1>
    <p>
        <em>Typed Argument Parsing with Pydantic</em>
    </p>
    <a href="https://pypi.python.org/pypi/pydantic-argparse">
        <img src="https://img.shields.io/pypi/v/pydantic-argparse.svg">
    </a>
    <a href="https://pepy.tech/project/pydantic-argparse">
        <img src="https://pepy.tech/badge/pydantic-argparse">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse">
        <img src="https://img.shields.io/pypi/pyversions/pydantic-argparse.svg">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/blob/master/LICENSE">
        <img src="https://img.shields.io/github/license/SupImDos/pydantic-argparse.svg">
    </a>
    <br>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/tests.yml?label=tests">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml">
        <img src="https://img.shields.io/coveralls/github/SupImDos/pydantic-argparse">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/linting.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/linting.yml?label=linting">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/typing.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/typing.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")
    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_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] --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": 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/9d/68/f67377429bb0fb8718dc841beafd3eade66824fc90de87c31a4d5caa2f68/pydantic_argparse-0.9.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n    <a href=\"https://pydantic-argparse.supimdos.com\">\n        <img src=\"https://raw.githubusercontent.com/SupImDos/pydantic-argparse/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-argparse\">\n        <img src=\"https://img.shields.io/pypi/v/pydantic-argparse.svg\">\n    </a>\n    <a href=\"https://pepy.tech/project/pydantic-argparse\">\n        <img src=\"https://pepy.tech/badge/pydantic-argparse\">\n    </a>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse\">\n        <img src=\"https://img.shields.io/pypi/pyversions/pydantic-argparse.svg\">\n    </a>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse/blob/master/LICENSE\">\n        <img src=\"https://img.shields.io/github/license/SupImDos/pydantic-argparse.svg\">\n    </a>\n    <br>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml\">\n        <img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/tests.yml?label=tests\">\n    </a>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml\">\n        <img src=\"https://img.shields.io/coveralls/github/SupImDos/pydantic-argparse\">\n    </a>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/linting.yml\">\n        <img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/linting.yml?label=linting\">\n    </a>\n    <a href=\"https://github.com/SupImDos/pydantic-argparse/actions/workflows/typing.yml\">\n        <img src=\"https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/typing.yml?label=typing\">\n    </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\nimport pydantic_argparse\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_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] --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 License\n        \n        Copyright (c) 2021 Hayden Richards\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "Typed Argument Parsing with Pydantic",
    "version": "0.9.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": "31fbea4f0f4c67e02396035f0706dcb48b2f0168ab6a2e40e98449c2e83a3bbd",
                "md5": "b515a3b53948ee4ffaca20cddad82daa",
                "sha256": "d577b3b5e9628e18fea9d37bfbf12dde380fbc6277ac776a30e28106f2c306aa"
            },
            "downloads": -1,
            "filename": "pydantic_argparse-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b515a3b53948ee4ffaca20cddad82daa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 25913,
            "upload_time": "2024-04-29T08:39:51",
            "upload_time_iso_8601": "2024-04-29T08:39:51.252565Z",
            "url": "https://files.pythonhosted.org/packages/31/fb/ea4f0f4c67e02396035f0706dcb48b2f0168ab6a2e40e98449c2e83a3bbd/pydantic_argparse-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9d68f67377429bb0fb8718dc841beafd3eade66824fc90de87c31a4d5caa2f68",
                "md5": "ac743702a13ba63b2dae1d344ca990de",
                "sha256": "01ed0996102301b1269124fd4dd2677d3909e6d930ab86085552c465c8f3aa79"
            },
            "downloads": -1,
            "filename": "pydantic_argparse-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ac743702a13ba63b2dae1d344ca990de",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15731,
            "upload_time": "2024-04-29T08:39:52",
            "upload_time_iso_8601": "2024-04-29T08:39:52.667664Z",
            "url": "https://files.pythonhosted.org/packages/9d/68/f67377429bb0fb8718dc841beafd3eade66824fc90de87c31a4d5caa2f68/pydantic_argparse-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 08:39:52",
    "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"
}
        
Elapsed time: 0.22887s